]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.10-201309062014.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.10-201309062014.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_gmr.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
39889 index 3751730..1a0bf07 100644
39890 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
39891 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
39892 @@ -29,7 +29,9 @@
39893 #include <drm/drmP.h>
39894 #include <drm/ttm/ttm_bo_driver.h>
39895
39896 -#define VMW_PPN_SIZE sizeof(unsigned long)
39897 +#define VMW_PPN_SIZE (sizeof(unsigned long))
39898 +/* A future safe maximum remap size. */
39899 +#define VMW_PPN_PER_REMAP ((31 * 1024) / VMW_PPN_SIZE)
39900
39901 static int vmw_gmr2_bind(struct vmw_private *dev_priv,
39902 struct page *pages[],
39903 @@ -38,43 +40,61 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv,
39904 {
39905 SVGAFifoCmdDefineGMR2 define_cmd;
39906 SVGAFifoCmdRemapGMR2 remap_cmd;
39907 - uint32_t define_size = sizeof(define_cmd) + 4;
39908 - uint32_t remap_size = VMW_PPN_SIZE * num_pages + sizeof(remap_cmd) + 4;
39909 uint32_t *cmd;
39910 uint32_t *cmd_orig;
39911 + uint32_t define_size = sizeof(define_cmd) + sizeof(*cmd);
39912 + uint32_t remap_num = num_pages / VMW_PPN_PER_REMAP + ((num_pages % VMW_PPN_PER_REMAP) > 0);
39913 + uint32_t remap_size = VMW_PPN_SIZE * num_pages + (sizeof(remap_cmd) + sizeof(*cmd)) * remap_num;
39914 + uint32_t remap_pos = 0;
39915 + uint32_t cmd_size = define_size + remap_size;
39916 uint32_t i;
39917
39918 - cmd_orig = cmd = vmw_fifo_reserve(dev_priv, define_size + remap_size);
39919 + cmd_orig = cmd = vmw_fifo_reserve(dev_priv, cmd_size);
39920 if (unlikely(cmd == NULL))
39921 return -ENOMEM;
39922
39923 define_cmd.gmrId = gmr_id;
39924 define_cmd.numPages = num_pages;
39925
39926 + *cmd++ = SVGA_CMD_DEFINE_GMR2;
39927 + memcpy(cmd, &define_cmd, sizeof(define_cmd));
39928 + cmd += sizeof(define_cmd) / sizeof(*cmd);
39929 +
39930 + /*
39931 + * Need to split the command if there are too many
39932 + * pages that goes into the gmr.
39933 + */
39934 +
39935 remap_cmd.gmrId = gmr_id;
39936 remap_cmd.flags = (VMW_PPN_SIZE > sizeof(*cmd)) ?
39937 SVGA_REMAP_GMR2_PPN64 : SVGA_REMAP_GMR2_PPN32;
39938 - remap_cmd.offsetPages = 0;
39939 - remap_cmd.numPages = num_pages;
39940
39941 - *cmd++ = SVGA_CMD_DEFINE_GMR2;
39942 - memcpy(cmd, &define_cmd, sizeof(define_cmd));
39943 - cmd += sizeof(define_cmd) / sizeof(uint32);
39944 + while (num_pages > 0) {
39945 + unsigned long nr = min(num_pages, (unsigned long)VMW_PPN_PER_REMAP);
39946
39947 - *cmd++ = SVGA_CMD_REMAP_GMR2;
39948 - memcpy(cmd, &remap_cmd, sizeof(remap_cmd));
39949 - cmd += sizeof(remap_cmd) / sizeof(uint32);
39950 + remap_cmd.offsetPages = remap_pos;
39951 + remap_cmd.numPages = nr;
39952
39953 - for (i = 0; i < num_pages; ++i) {
39954 - if (VMW_PPN_SIZE <= 4)
39955 - *cmd = page_to_pfn(*pages++);
39956 - else
39957 - *((uint64_t *)cmd) = page_to_pfn(*pages++);
39958 + *cmd++ = SVGA_CMD_REMAP_GMR2;
39959 + memcpy(cmd, &remap_cmd, sizeof(remap_cmd));
39960 + cmd += sizeof(remap_cmd) / sizeof(*cmd);
39961
39962 - cmd += VMW_PPN_SIZE / sizeof(*cmd);
39963 + for (i = 0; i < nr; ++i) {
39964 + if (VMW_PPN_SIZE <= 4)
39965 + *cmd = page_to_pfn(*pages++);
39966 + else
39967 + *((uint64_t *)cmd) = page_to_pfn(*pages++);
39968 +
39969 + cmd += VMW_PPN_SIZE / sizeof(*cmd);
39970 + }
39971 +
39972 + num_pages -= nr;
39973 + remap_pos += nr;
39974 }
39975
39976 - vmw_fifo_commit(dev_priv, define_size + remap_size);
39977 + BUG_ON(cmd != cmd_orig + cmd_size / sizeof(*cmd));
39978 +
39979 + vmw_fifo_commit(dev_priv, cmd_size);
39980
39981 return 0;
39982 }
39983 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39984 index c509d40..3b640c3 100644
39985 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39986 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39987 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39988 int ret;
39989
39990 num_clips = arg->num_clips;
39991 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39992 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39993
39994 if (unlikely(num_clips == 0))
39995 return 0;
39996 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39997 int ret;
39998
39999 num_clips = arg->num_clips;
40000 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40001 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40002
40003 if (unlikely(num_clips == 0))
40004 return 0;
40005 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40006 index 4640adb..e1384ed 100644
40007 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40008 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40009 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
40010 * emitted. Then the fence is stale and signaled.
40011 */
40012
40013 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
40014 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
40015 > VMW_FENCE_WRAP);
40016
40017 return ret;
40018 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
40019
40020 if (fifo_idle)
40021 down_read(&fifo_state->rwsem);
40022 - signal_seq = atomic_read(&dev_priv->marker_seq);
40023 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
40024 ret = 0;
40025
40026 for (;;) {
40027 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40028 index 8a8725c2..afed796 100644
40029 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40030 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40031 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
40032 while (!vmw_lag_lt(queue, us)) {
40033 spin_lock(&queue->lock);
40034 if (list_empty(&queue->head))
40035 - seqno = atomic_read(&dev_priv->marker_seq);
40036 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40037 else {
40038 marker = list_first_entry(&queue->head,
40039 struct vmw_marker, head);
40040 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
40041 index 8c04943..4370ed9 100644
40042 --- a/drivers/gpu/host1x/drm/dc.c
40043 +++ b/drivers/gpu/host1x/drm/dc.c
40044 @@ -999,7 +999,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
40045 }
40046
40047 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
40048 - dc->debugfs_files[i].data = dc;
40049 + *(void **)&dc->debugfs_files[i].data = dc;
40050
40051 err = drm_debugfs_create_files(dc->debugfs_files,
40052 ARRAY_SIZE(debugfs_files),
40053 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
40054 index 402f486..5340852 100644
40055 --- a/drivers/hid/hid-core.c
40056 +++ b/drivers/hid/hid-core.c
40057 @@ -63,6 +63,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
40058 struct hid_report_enum *report_enum = device->report_enum + type;
40059 struct hid_report *report;
40060
40061 + if (id >= HID_MAX_IDS)
40062 + return NULL;
40063 if (report_enum->report_id_hash[id])
40064 return report_enum->report_id_hash[id];
40065
40066 @@ -404,8 +406,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
40067
40068 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
40069 parser->global.report_id = item_udata(item);
40070 - if (parser->global.report_id == 0) {
40071 - hid_err(parser->device, "report_id 0 is invalid\n");
40072 + if (parser->global.report_id == 0 ||
40073 + parser->global.report_id >= HID_MAX_IDS) {
40074 + hid_err(parser->device, "report_id %u is invalid\n",
40075 + parser->global.report_id);
40076 return -1;
40077 }
40078 return 0;
40079 @@ -575,7 +579,7 @@ static void hid_close_report(struct hid_device *device)
40080 for (i = 0; i < HID_REPORT_TYPES; i++) {
40081 struct hid_report_enum *report_enum = device->report_enum + i;
40082
40083 - for (j = 0; j < 256; j++) {
40084 + for (j = 0; j < HID_MAX_IDS; j++) {
40085 struct hid_report *report = report_enum->report_id_hash[j];
40086 if (report)
40087 hid_free_report(report);
40088 @@ -755,6 +759,56 @@ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
40089 }
40090 EXPORT_SYMBOL_GPL(hid_parse_report);
40091
40092 +static const char * const hid_report_names[] = {
40093 + "HID_INPUT_REPORT",
40094 + "HID_OUTPUT_REPORT",
40095 + "HID_FEATURE_REPORT",
40096 +};
40097 +/**
40098 + * hid_validate_report - validate existing device report
40099 + *
40100 + * @device: hid device
40101 + * @type: which report type to examine
40102 + * @id: which report ID to examine (0 for first)
40103 + * @fields: expected number of fields
40104 + * @report_counts: expected number of values per field
40105 + *
40106 + * Validate the report details after parsing.
40107 + */
40108 +struct hid_report *hid_validate_report(struct hid_device *hid,
40109 + unsigned int type, unsigned int id,
40110 + unsigned int fields,
40111 + unsigned int report_counts)
40112 +{
40113 + struct hid_report *report;
40114 + unsigned int i;
40115 +
40116 + if (type > HID_FEATURE_REPORT) {
40117 + hid_err(hid, "invalid HID report %u\n", type);
40118 + return NULL;
40119 + }
40120 +
40121 + report = hid->report_enum[type].report_id_hash[id];
40122 + if (!report) {
40123 + hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
40124 + return NULL;
40125 + }
40126 + if (report->maxfield < fields) {
40127 + hid_err(hid, "not enough fields in %s %u\n",
40128 + hid_report_names[type], id);
40129 + return NULL;
40130 + }
40131 + for (i = 0; i < fields; i++) {
40132 + if (report->field[i]->report_count < report_counts) {
40133 + hid_err(hid, "not enough values in %s %u fields\n",
40134 + hid_report_names[type], id);
40135 + return NULL;
40136 + }
40137 + }
40138 + return report;
40139 +}
40140 +EXPORT_SYMBOL_GPL(hid_validate_report);
40141 +
40142 /**
40143 * hid_open_report - open a driver-specific device report
40144 *
40145 @@ -1152,7 +1206,12 @@ EXPORT_SYMBOL_GPL(hid_output_report);
40146
40147 int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
40148 {
40149 - unsigned size = field->report_size;
40150 + unsigned size;
40151 +
40152 + if (!field)
40153 + return -1;
40154 +
40155 + size = field->report_size;
40156
40157 hid_dump_input(field->report->device, field->usage + offset, value);
40158
40159 @@ -2275,7 +2334,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
40160
40161 int hid_add_device(struct hid_device *hdev)
40162 {
40163 - static atomic_t id = ATOMIC_INIT(0);
40164 + static atomic_unchecked_t id = ATOMIC_INIT(0);
40165 int ret;
40166
40167 if (WARN_ON(hdev->status & HID_STAT_ADDED))
40168 @@ -2309,7 +2368,7 @@ int hid_add_device(struct hid_device *hdev)
40169 /* XXX hack, any other cleaner solution after the driver core
40170 * is converted to allow more than 20 bytes as the device name? */
40171 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
40172 - hdev->vendor, hdev->product, atomic_inc_return(&id));
40173 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
40174
40175 hid_debug_register(hdev, dev_name(&hdev->dev));
40176 ret = device_add(&hdev->dev);
40177 diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
40178 index 07837f5..b697ada 100644
40179 --- a/drivers/hid/hid-lenovo-tpkbd.c
40180 +++ b/drivers/hid/hid-lenovo-tpkbd.c
40181 @@ -341,6 +341,11 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
40182 char *name_mute, *name_micmute;
40183 int ret;
40184
40185 + /* Validate required reports. */
40186 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 4, 4, 1) ||
40187 + !hid_validate_report(hdev, HID_OUTPUT_REPORT, 3, 1, 2))
40188 + return -ENODEV;
40189 +
40190 if (sysfs_create_group(&hdev->dev.kobj,
40191 &tpkbd_attr_group_pointer)) {
40192 hid_warn(hdev, "Could not create sysfs group\n");
40193 diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
40194 index b3cd150..9805197 100644
40195 --- a/drivers/hid/hid-lg2ff.c
40196 +++ b/drivers/hid/hid-lg2ff.c
40197 @@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid)
40198 struct hid_report *report;
40199 struct hid_input *hidinput = list_entry(hid->inputs.next,
40200 struct hid_input, list);
40201 - struct list_head *report_list =
40202 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40203 struct input_dev *dev = hidinput->input;
40204 int error;
40205
40206 - if (list_empty(report_list)) {
40207 - hid_err(hid, "no output report found\n");
40208 + /* Check that the report looks ok */
40209 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7);
40210 + if (!report)
40211 return -ENODEV;
40212 - }
40213 -
40214 - report = list_entry(report_list->next, struct hid_report, list);
40215 -
40216 - if (report->maxfield < 1) {
40217 - hid_err(hid, "output report is empty\n");
40218 - return -ENODEV;
40219 - }
40220 - if (report->field[0]->report_count < 7) {
40221 - hid_err(hid, "not enough values in the field\n");
40222 - return -ENODEV;
40223 - }
40224
40225 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
40226 if (!lg2ff)
40227 diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
40228 index e52f181..53ac79b 100644
40229 --- a/drivers/hid/hid-lg3ff.c
40230 +++ b/drivers/hid/hid-lg3ff.c
40231 @@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data,
40232 int x, y;
40233
40234 /*
40235 - * Maxusage should always be 63 (maximum fields)
40236 - * likely a better way to ensure this data is clean
40237 + * Available values in the field should always be 63, but we only use up to
40238 + * 35. Instead, clear the entire area, however big it is.
40239 */
40240 - memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);
40241 + memset(report->field[0]->value, 0,
40242 + sizeof(__s32) * report->field[0]->report_count);
40243
40244 switch (effect->type) {
40245 case FF_CONSTANT:
40246 @@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = {
40247 int lg3ff_init(struct hid_device *hid)
40248 {
40249 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
40250 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40251 struct input_dev *dev = hidinput->input;
40252 - struct hid_report *report;
40253 - struct hid_field *field;
40254 const signed short *ff_bits = ff3_joystick_ac;
40255 int error;
40256 int i;
40257
40258 - /* Find the report to use */
40259 - if (list_empty(report_list)) {
40260 - hid_err(hid, "No output report found\n");
40261 - return -1;
40262 - }
40263 -
40264 /* Check that the report looks ok */
40265 - report = list_entry(report_list->next, struct hid_report, list);
40266 - if (!report) {
40267 - hid_err(hid, "NULL output report\n");
40268 - return -1;
40269 - }
40270 -
40271 - field = report->field[0];
40272 - if (!field) {
40273 - hid_err(hid, "NULL field\n");
40274 - return -1;
40275 - }
40276 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 35))
40277 + return -ENODEV;
40278
40279 /* Assume single fixed device G940 */
40280 for (i = 0; ff_bits[i] >= 0; i++)
40281 diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
40282 index 0ddae2a..8b89f0f 100644
40283 --- a/drivers/hid/hid-lg4ff.c
40284 +++ b/drivers/hid/hid-lg4ff.c
40285 @@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
40286 int lg4ff_init(struct hid_device *hid)
40287 {
40288 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
40289 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40290 struct input_dev *dev = hidinput->input;
40291 - struct hid_report *report;
40292 - struct hid_field *field;
40293 struct lg4ff_device_entry *entry;
40294 struct lg_drv_data *drv_data;
40295 struct usb_device_descriptor *udesc;
40296 int error, i, j;
40297 __u16 bcdDevice, rev_maj, rev_min;
40298
40299 - /* Find the report to use */
40300 - if (list_empty(report_list)) {
40301 - hid_err(hid, "No output report found\n");
40302 - return -1;
40303 - }
40304 -
40305 /* Check that the report looks ok */
40306 - report = list_entry(report_list->next, struct hid_report, list);
40307 - if (!report) {
40308 - hid_err(hid, "NULL output report\n");
40309 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
40310 return -1;
40311 - }
40312 -
40313 - field = report->field[0];
40314 - if (!field) {
40315 - hid_err(hid, "NULL field\n");
40316 - return -1;
40317 - }
40318
40319 /* Check what wheel has been connected */
40320 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
40321 diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
40322 index d7ea8c8..a84fb40 100644
40323 --- a/drivers/hid/hid-lgff.c
40324 +++ b/drivers/hid/hid-lgff.c
40325 @@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
40326 int lgff_init(struct hid_device* hid)
40327 {
40328 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
40329 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40330 struct input_dev *dev = hidinput->input;
40331 - struct hid_report *report;
40332 - struct hid_field *field;
40333 const signed short *ff_bits = ff_joystick;
40334 int error;
40335 int i;
40336
40337 - /* Find the report to use */
40338 - if (list_empty(report_list)) {
40339 - hid_err(hid, "No output report found\n");
40340 - return -1;
40341 - }
40342 -
40343 /* Check that the report looks ok */
40344 - report = list_entry(report_list->next, struct hid_report, list);
40345 - field = report->field[0];
40346 - if (!field) {
40347 - hid_err(hid, "NULL field\n");
40348 - return -1;
40349 - }
40350 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
40351 + return -ENODEV;
40352
40353 for (i = 0; i < ARRAY_SIZE(devices); i++) {
40354 if (dev->id.vendor == devices[i].idVendor &&
40355 diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
40356 index 5207591a..6c9197f 100644
40357 --- a/drivers/hid/hid-logitech-dj.c
40358 +++ b/drivers/hid/hid-logitech-dj.c
40359 @@ -421,7 +421,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
40360 struct hid_report *report;
40361 struct hid_report_enum *output_report_enum;
40362 u8 *data = (u8 *)(&dj_report->device_index);
40363 - int i;
40364 + unsigned int i, length;
40365
40366 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
40367 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
40368 @@ -431,7 +431,9 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
40369 return -ENODEV;
40370 }
40371
40372 - for (i = 0; i < report->field[0]->report_count; i++)
40373 + length = min_t(size_t, sizeof(*dj_report) - 1,
40374 + report->field[0]->report_count);
40375 + for (i = 0; i < length; i++)
40376 report->field[0]->value[i] = data[i];
40377
40378 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
40379 @@ -738,6 +740,12 @@ static int logi_dj_probe(struct hid_device *hdev,
40380 goto hid_parse_fail;
40381 }
40382
40383 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
40384 + 1, 3)) {
40385 + retval = -ENODEV;
40386 + goto hid_parse_fail;
40387 + }
40388 +
40389 /* Starts the usb device and connects to upper interfaces hiddev and
40390 * hidraw */
40391 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
40392 diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
40393 index d39a5ce..4892dfc 100644
40394 --- a/drivers/hid/hid-multitouch.c
40395 +++ b/drivers/hid/hid-multitouch.c
40396 @@ -330,9 +330,18 @@ static void mt_feature_mapping(struct hid_device *hdev,
40397 break;
40398 }
40399 }
40400 + /* Ignore if value index is out of bounds. */
40401 + if (td->inputmode_index < 0 ||
40402 + td->inputmode_index >= field->report_count) {
40403 + dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n");
40404 + td->inputmode = -1;
40405 + }
40406
40407 break;
40408 case HID_DG_CONTACTMAX:
40409 + /* Ignore if value count is out of bounds. */
40410 + if (field->report_count < 1)
40411 + break;
40412 td->maxcontact_report_id = field->report->id;
40413 td->maxcontacts = field->value[0];
40414 if (!td->maxcontacts &&
40415 @@ -743,15 +752,21 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
40416 unsigned count;
40417 int r, n;
40418
40419 + if (report->maxfield == 0)
40420 + return;
40421 +
40422 /*
40423 * Includes multi-packet support where subsequent
40424 * packets are sent with zero contactcount.
40425 */
40426 - if (td->cc_index >= 0) {
40427 - struct hid_field *field = report->field[td->cc_index];
40428 - int value = field->value[td->cc_value_index];
40429 - if (value)
40430 - td->num_expected = value;
40431 + if (td->cc_index >= 0 && td->cc_index < report->maxfield) {
40432 + field = report->field[td->cc_index];
40433 + if (td->cc_value_index >= 0 &&
40434 + td->cc_value_index < field->report_count) {
40435 + int value = field->value[td->cc_value_index];
40436 + if (value)
40437 + td->num_expected = value;
40438 + }
40439 }
40440
40441 for (r = 0; r < report->maxfield; r++) {
40442 diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
40443 index ef95102..5482156 100644
40444 --- a/drivers/hid/hid-ntrig.c
40445 +++ b/drivers/hid/hid-ntrig.c
40446 @@ -115,7 +115,8 @@ static inline int ntrig_get_mode(struct hid_device *hdev)
40447 struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
40448 report_id_hash[0x0d];
40449
40450 - if (!report)
40451 + if (!report || report->maxfield < 1 ||
40452 + report->field[0]->report_count < 1)
40453 return -EINVAL;
40454
40455 hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
40456 diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
40457 index b48092d..72bba1e 100644
40458 --- a/drivers/hid/hid-picolcd_core.c
40459 +++ b/drivers/hid/hid-picolcd_core.c
40460 @@ -290,7 +290,7 @@ static ssize_t picolcd_operation_mode_store(struct device *dev,
40461 buf += 10;
40462 cnt -= 10;
40463 }
40464 - if (!report)
40465 + if (!report || report->maxfield < 1)
40466 return -EINVAL;
40467
40468 while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r'))
40469 diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
40470 index d29112f..2dcd7d9 100644
40471 --- a/drivers/hid/hid-pl.c
40472 +++ b/drivers/hid/hid-pl.c
40473 @@ -132,8 +132,14 @@ static int plff_init(struct hid_device *hid)
40474 strong = &report->field[0]->value[2];
40475 weak = &report->field[0]->value[3];
40476 debug("detected single-field device");
40477 - } else if (report->maxfield >= 4 && report->field[0]->maxusage == 1 &&
40478 - report->field[0]->usage[0].hid == (HID_UP_LED | 0x43)) {
40479 + } else if (report->field[0]->maxusage == 1 &&
40480 + report->field[0]->usage[0].hid ==
40481 + (HID_UP_LED | 0x43) &&
40482 + report->maxfield >= 4 &&
40483 + report->field[0]->report_count >= 1 &&
40484 + report->field[1]->report_count >= 1 &&
40485 + report->field[2]->report_count >= 1 &&
40486 + report->field[3]->report_count >= 1) {
40487 report->field[0]->value[0] = 0x00;
40488 report->field[1]->value[0] = 0x00;
40489 strong = &report->field[2]->value[0];
40490 diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
40491 index ca749810..aa34755 100644
40492 --- a/drivers/hid/hid-sensor-hub.c
40493 +++ b/drivers/hid/hid-sensor-hub.c
40494 @@ -221,7 +221,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
40495
40496 mutex_lock(&data->mutex);
40497 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
40498 - if (!report || (field_index >= report->maxfield)) {
40499 + if (!report || (field_index >= report->maxfield) ||
40500 + report->field[field_index]->report_count < 1) {
40501 ret = -EINVAL;
40502 goto done_proc;
40503 }
40504 diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
40505 index d164911..ef42e86 100644
40506 --- a/drivers/hid/hid-steelseries.c
40507 +++ b/drivers/hid/hid-steelseries.c
40508 @@ -249,6 +249,11 @@ static int steelseries_srws1_probe(struct hid_device *hdev,
40509 goto err_free;
40510 }
40511
40512 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 0, 1, 16)) {
40513 + ret = -ENODEV;
40514 + goto err_free;
40515 + }
40516 +
40517 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
40518 if (ret) {
40519 hid_err(hdev, "hw start failed\n");
40520 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
40521 index 90124ff..3761764 100644
40522 --- a/drivers/hid/hid-wiimote-debug.c
40523 +++ b/drivers/hid/hid-wiimote-debug.c
40524 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
40525 else if (size == 0)
40526 return -EIO;
40527
40528 - if (copy_to_user(u, buf, size))
40529 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
40530 return -EFAULT;
40531
40532 *off += size;
40533 diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
40534 index 6ec28a3..b124991 100644
40535 --- a/drivers/hid/hid-zpff.c
40536 +++ b/drivers/hid/hid-zpff.c
40537 @@ -68,22 +68,12 @@ static int zpff_init(struct hid_device *hid)
40538 struct hid_report *report;
40539 struct hid_input *hidinput = list_entry(hid->inputs.next,
40540 struct hid_input, list);
40541 - struct list_head *report_list =
40542 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40543 struct input_dev *dev = hidinput->input;
40544 int error;
40545
40546 - if (list_empty(report_list)) {
40547 - hid_err(hid, "no output report found\n");
40548 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 4, 1);
40549 + if (!report)
40550 return -ENODEV;
40551 - }
40552 -
40553 - report = list_entry(report_list->next, struct hid_report, list);
40554 -
40555 - if (report->maxfield < 4) {
40556 - hid_err(hid, "not enough fields in report\n");
40557 - return -ENODEV;
40558 - }
40559
40560 zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);
40561 if (!zpff)
40562 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
40563 index fc307e0..2b255e8 100644
40564 --- a/drivers/hid/uhid.c
40565 +++ b/drivers/hid/uhid.c
40566 @@ -47,7 +47,7 @@ struct uhid_device {
40567 struct mutex report_lock;
40568 wait_queue_head_t report_wait;
40569 atomic_t report_done;
40570 - atomic_t report_id;
40571 + atomic_unchecked_t report_id;
40572 struct uhid_event report_buf;
40573 };
40574
40575 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
40576
40577 spin_lock_irqsave(&uhid->qlock, flags);
40578 ev->type = UHID_FEATURE;
40579 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
40580 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
40581 ev->u.feature.rnum = rnum;
40582 ev->u.feature.rtype = report_type;
40583
40584 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
40585 spin_lock_irqsave(&uhid->qlock, flags);
40586
40587 /* id for old report; drop it silently */
40588 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
40589 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
40590 goto unlock;
40591 if (atomic_read(&uhid->report_done))
40592 goto unlock;
40593 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
40594 index 0b122f8..b1d8160 100644
40595 --- a/drivers/hv/channel.c
40596 +++ b/drivers/hv/channel.c
40597 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
40598 int ret = 0;
40599 int t;
40600
40601 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
40602 - atomic_inc(&vmbus_connection.next_gpadl_handle);
40603 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
40604 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
40605
40606 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
40607 if (ret)
40608 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
40609 index ae49237..380d4c9 100644
40610 --- a/drivers/hv/hv.c
40611 +++ b/drivers/hv/hv.c
40612 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
40613 u64 output_address = (output) ? virt_to_phys(output) : 0;
40614 u32 output_address_hi = output_address >> 32;
40615 u32 output_address_lo = output_address & 0xFFFFFFFF;
40616 - void *hypercall_page = hv_context.hypercall_page;
40617 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
40618
40619 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
40620 "=a"(hv_status_lo) : "d" (control_hi),
40621 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
40622 index deb5c25..ed2d4fd 100644
40623 --- a/drivers/hv/hv_balloon.c
40624 +++ b/drivers/hv/hv_balloon.c
40625 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
40626
40627 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
40628 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
40629 -static atomic_t trans_id = ATOMIC_INIT(0);
40630 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
40631
40632 static int dm_ring_size = (5 * PAGE_SIZE);
40633
40634 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
40635 memset(&resp, 0, sizeof(struct dm_hot_add_response));
40636 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
40637 resp.hdr.size = sizeof(struct dm_hot_add_response);
40638 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40639 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40640
40641 #ifdef CONFIG_MEMORY_HOTPLUG
40642 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
40643 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
40644 memset(&status, 0, sizeof(struct dm_status));
40645 status.hdr.type = DM_STATUS_REPORT;
40646 status.hdr.size = sizeof(struct dm_status);
40647 - status.hdr.trans_id = atomic_inc_return(&trans_id);
40648 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40649
40650 /*
40651 * The host expects the guest to report free memory.
40652 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
40653 * send the status. This can happen if we were interrupted
40654 * after we picked our transaction ID.
40655 */
40656 - if (status.hdr.trans_id != atomic_read(&trans_id))
40657 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
40658 return;
40659
40660 vmbus_sendpacket(dm->dev->channel, &status,
40661 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
40662 bl_resp = (struct dm_balloon_response *)send_buffer;
40663 memset(send_buffer, 0, PAGE_SIZE);
40664 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
40665 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
40666 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40667 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
40668 bl_resp->more_pages = 1;
40669
40670 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
40671
40672 memset(&resp, 0, sizeof(struct dm_unballoon_response));
40673 resp.hdr.type = DM_UNBALLOON_RESPONSE;
40674 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40675 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40676 resp.hdr.size = sizeof(struct dm_unballoon_response);
40677
40678 vmbus_sendpacket(dm_device.dev->channel, &resp,
40679 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
40680 memset(&version_req, 0, sizeof(struct dm_version_request));
40681 version_req.hdr.type = DM_VERSION_REQUEST;
40682 version_req.hdr.size = sizeof(struct dm_version_request);
40683 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40684 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40685 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
40686 version_req.is_last_attempt = 1;
40687
40688 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40689 memset(&version_req, 0, sizeof(struct dm_version_request));
40690 version_req.hdr.type = DM_VERSION_REQUEST;
40691 version_req.hdr.size = sizeof(struct dm_version_request);
40692 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40693 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40694 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40695 version_req.is_last_attempt = 0;
40696
40697 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40698 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40699 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40700 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40701 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40702 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40703
40704 cap_msg.caps.cap_bits.balloon = 1;
40705 cap_msg.caps.cap_bits.hot_add = 1;
40706 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40707 index 12f2f9e..679603c 100644
40708 --- a/drivers/hv/hyperv_vmbus.h
40709 +++ b/drivers/hv/hyperv_vmbus.h
40710 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
40711 struct vmbus_connection {
40712 enum vmbus_connect_state conn_state;
40713
40714 - atomic_t next_gpadl_handle;
40715 + atomic_unchecked_t next_gpadl_handle;
40716
40717 /*
40718 * Represents channel interrupts. Each bit position represents a
40719 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40720 index 4004e54..c2de226 100644
40721 --- a/drivers/hv/vmbus_drv.c
40722 +++ b/drivers/hv/vmbus_drv.c
40723 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40724 {
40725 int ret = 0;
40726
40727 - static atomic_t device_num = ATOMIC_INIT(0);
40728 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40729
40730 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40731 - atomic_inc_return(&device_num));
40732 + atomic_inc_return_unchecked(&device_num));
40733
40734 child_device_obj->device.bus = &hv_bus;
40735 child_device_obj->device.parent = &hv_acpi_dev->dev;
40736 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40737 index 6351aba..dc4aaf4 100644
40738 --- a/drivers/hwmon/acpi_power_meter.c
40739 +++ b/drivers/hwmon/acpi_power_meter.c
40740 @@ -117,7 +117,7 @@ struct sensor_template {
40741 struct device_attribute *devattr,
40742 const char *buf, size_t count);
40743 int index;
40744 -};
40745 +} __do_const;
40746
40747 /* Averaging interval */
40748 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40749 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40750 struct sensor_template *attrs)
40751 {
40752 struct device *dev = &resource->acpi_dev->dev;
40753 - struct sensor_device_attribute *sensors =
40754 + sensor_device_attribute_no_const *sensors =
40755 &resource->sensors[resource->num_sensors];
40756 int res = 0;
40757
40758 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40759 index 62c2e32..8f2859a 100644
40760 --- a/drivers/hwmon/applesmc.c
40761 +++ b/drivers/hwmon/applesmc.c
40762 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40763 {
40764 struct applesmc_node_group *grp;
40765 struct applesmc_dev_attr *node;
40766 - struct attribute *attr;
40767 + attribute_no_const *attr;
40768 int ret, i;
40769
40770 for (grp = groups; grp->format; grp++) {
40771 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40772 index b25c643..a13460d 100644
40773 --- a/drivers/hwmon/asus_atk0110.c
40774 +++ b/drivers/hwmon/asus_atk0110.c
40775 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40776 struct atk_sensor_data {
40777 struct list_head list;
40778 struct atk_data *data;
40779 - struct device_attribute label_attr;
40780 - struct device_attribute input_attr;
40781 - struct device_attribute limit1_attr;
40782 - struct device_attribute limit2_attr;
40783 + device_attribute_no_const label_attr;
40784 + device_attribute_no_const input_attr;
40785 + device_attribute_no_const limit1_attr;
40786 + device_attribute_no_const limit2_attr;
40787 char label_attr_name[ATTR_NAME_SIZE];
40788 char input_attr_name[ATTR_NAME_SIZE];
40789 char limit1_attr_name[ATTR_NAME_SIZE];
40790 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40791 static struct device_attribute atk_name_attr =
40792 __ATTR(name, 0444, atk_name_show, NULL);
40793
40794 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40795 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40796 sysfs_show_func show)
40797 {
40798 sysfs_attr_init(&attr->attr);
40799 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40800 index 658ce3a..0d0c2f3 100644
40801 --- a/drivers/hwmon/coretemp.c
40802 +++ b/drivers/hwmon/coretemp.c
40803 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
40804 return NOTIFY_OK;
40805 }
40806
40807 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40808 +static struct notifier_block coretemp_cpu_notifier = {
40809 .notifier_call = coretemp_cpu_callback,
40810 };
40811
40812 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40813 index 1429f6e..ee03d59 100644
40814 --- a/drivers/hwmon/ibmaem.c
40815 +++ b/drivers/hwmon/ibmaem.c
40816 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40817 struct aem_rw_sensor_template *rw)
40818 {
40819 struct device *dev = &data->pdev->dev;
40820 - struct sensor_device_attribute *sensors = data->sensors;
40821 + sensor_device_attribute_no_const *sensors = data->sensors;
40822 int err;
40823
40824 /* Set up read-only sensors */
40825 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40826 index 52b77af..aed1ddf 100644
40827 --- a/drivers/hwmon/iio_hwmon.c
40828 +++ b/drivers/hwmon/iio_hwmon.c
40829 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40830 {
40831 struct device *dev = &pdev->dev;
40832 struct iio_hwmon_state *st;
40833 - struct sensor_device_attribute *a;
40834 + sensor_device_attribute_no_const *a;
40835 int ret, i;
40836 int in_i = 1, temp_i = 1, curr_i = 1;
40837 enum iio_chan_type type;
40838 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40839 index 9add6092..ee7ba3f 100644
40840 --- a/drivers/hwmon/pmbus/pmbus_core.c
40841 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40842 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40843 return 0;
40844 }
40845
40846 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40847 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40848 const char *name,
40849 umode_t mode,
40850 ssize_t (*show)(struct device *dev,
40851 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40852 dev_attr->store = store;
40853 }
40854
40855 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40856 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40857 const char *name,
40858 umode_t mode,
40859 ssize_t (*show)(struct device *dev,
40860 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40861 u16 reg, u8 mask)
40862 {
40863 struct pmbus_boolean *boolean;
40864 - struct sensor_device_attribute *a;
40865 + sensor_device_attribute_no_const *a;
40866
40867 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40868 if (!boolean)
40869 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40870 bool update, bool readonly)
40871 {
40872 struct pmbus_sensor *sensor;
40873 - struct device_attribute *a;
40874 + device_attribute_no_const *a;
40875
40876 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40877 if (!sensor)
40878 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40879 const char *lstring, int index)
40880 {
40881 struct pmbus_label *label;
40882 - struct device_attribute *a;
40883 + device_attribute_no_const *a;
40884
40885 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40886 if (!label)
40887 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40888 index 2507f90..1645765 100644
40889 --- a/drivers/hwmon/sht15.c
40890 +++ b/drivers/hwmon/sht15.c
40891 @@ -169,7 +169,7 @@ struct sht15_data {
40892 int supply_uv;
40893 bool supply_uv_valid;
40894 struct work_struct update_supply_work;
40895 - atomic_t interrupt_handled;
40896 + atomic_unchecked_t interrupt_handled;
40897 };
40898
40899 /**
40900 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40901 ret = gpio_direction_input(data->pdata->gpio_data);
40902 if (ret)
40903 return ret;
40904 - atomic_set(&data->interrupt_handled, 0);
40905 + atomic_set_unchecked(&data->interrupt_handled, 0);
40906
40907 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40908 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40909 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40910 /* Only relevant if the interrupt hasn't occurred. */
40911 - if (!atomic_read(&data->interrupt_handled))
40912 + if (!atomic_read_unchecked(&data->interrupt_handled))
40913 schedule_work(&data->read_work);
40914 }
40915 ret = wait_event_timeout(data->wait_queue,
40916 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40917
40918 /* First disable the interrupt */
40919 disable_irq_nosync(irq);
40920 - atomic_inc(&data->interrupt_handled);
40921 + atomic_inc_unchecked(&data->interrupt_handled);
40922 /* Then schedule a reading work struct */
40923 if (data->state != SHT15_READING_NOTHING)
40924 schedule_work(&data->read_work);
40925 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40926 * If not, then start the interrupt again - care here as could
40927 * have gone low in meantime so verify it hasn't!
40928 */
40929 - atomic_set(&data->interrupt_handled, 0);
40930 + atomic_set_unchecked(&data->interrupt_handled, 0);
40931 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40932 /* If still not occurred or another handler was scheduled */
40933 if (gpio_get_value(data->pdata->gpio_data)
40934 - || atomic_read(&data->interrupt_handled))
40935 + || atomic_read_unchecked(&data->interrupt_handled))
40936 return;
40937 }
40938
40939 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40940 index 76f157b..9c0db1b 100644
40941 --- a/drivers/hwmon/via-cputemp.c
40942 +++ b/drivers/hwmon/via-cputemp.c
40943 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
40944 return NOTIFY_OK;
40945 }
40946
40947 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40948 +static struct notifier_block via_cputemp_cpu_notifier = {
40949 .notifier_call = via_cputemp_cpu_callback,
40950 };
40951
40952 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40953 index 07f01ac..d79ad3d 100644
40954 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40955 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40956 @@ -43,7 +43,7 @@
40957 extern struct i2c_adapter amd756_smbus;
40958
40959 static struct i2c_adapter *s4882_adapter;
40960 -static struct i2c_algorithm *s4882_algo;
40961 +static i2c_algorithm_no_const *s4882_algo;
40962
40963 /* Wrapper access functions for multiplexed SMBus */
40964 static DEFINE_MUTEX(amd756_lock);
40965 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40966 index 2ca268d..c6acbdf 100644
40967 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40968 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40969 @@ -41,7 +41,7 @@
40970 extern struct i2c_adapter *nforce2_smbus;
40971
40972 static struct i2c_adapter *s4985_adapter;
40973 -static struct i2c_algorithm *s4985_algo;
40974 +static i2c_algorithm_no_const *s4985_algo;
40975
40976 /* Wrapper access functions for multiplexed SMBus */
40977 static DEFINE_MUTEX(nforce2_lock);
40978 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40979 index c3ccdea..5b3dc1a 100644
40980 --- a/drivers/i2c/i2c-dev.c
40981 +++ b/drivers/i2c/i2c-dev.c
40982 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40983 break;
40984 }
40985
40986 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40987 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40988 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40989 if (IS_ERR(rdwr_pa[i].buf)) {
40990 res = PTR_ERR(rdwr_pa[i].buf);
40991 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40992 index 2ff6204..218c16e 100644
40993 --- a/drivers/ide/ide-cd.c
40994 +++ b/drivers/ide/ide-cd.c
40995 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40996 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40997 if ((unsigned long)buf & alignment
40998 || blk_rq_bytes(rq) & q->dma_pad_mask
40999 - || object_is_on_stack(buf))
41000 + || object_starts_on_stack(buf))
41001 drive->dma = 0;
41002 }
41003 }
41004 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
41005 index e145931..08bfc59 100644
41006 --- a/drivers/iio/industrialio-core.c
41007 +++ b/drivers/iio/industrialio-core.c
41008 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
41009 }
41010
41011 static
41012 -int __iio_device_attr_init(struct device_attribute *dev_attr,
41013 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
41014 const char *postfix,
41015 struct iio_chan_spec const *chan,
41016 ssize_t (*readfunc)(struct device *dev,
41017 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
41018 index 784b97c..c9ceadf 100644
41019 --- a/drivers/infiniband/core/cm.c
41020 +++ b/drivers/infiniband/core/cm.c
41021 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
41022
41023 struct cm_counter_group {
41024 struct kobject obj;
41025 - atomic_long_t counter[CM_ATTR_COUNT];
41026 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
41027 };
41028
41029 struct cm_counter_attribute {
41030 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
41031 struct ib_mad_send_buf *msg = NULL;
41032 int ret;
41033
41034 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41035 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41036 counter[CM_REQ_COUNTER]);
41037
41038 /* Quick state check to discard duplicate REQs. */
41039 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
41040 if (!cm_id_priv)
41041 return;
41042
41043 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41044 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41045 counter[CM_REP_COUNTER]);
41046 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
41047 if (ret)
41048 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
41049 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
41050 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
41051 spin_unlock_irq(&cm_id_priv->lock);
41052 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41053 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41054 counter[CM_RTU_COUNTER]);
41055 goto out;
41056 }
41057 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
41058 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
41059 dreq_msg->local_comm_id);
41060 if (!cm_id_priv) {
41061 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41062 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41063 counter[CM_DREQ_COUNTER]);
41064 cm_issue_drep(work->port, work->mad_recv_wc);
41065 return -EINVAL;
41066 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
41067 case IB_CM_MRA_REP_RCVD:
41068 break;
41069 case IB_CM_TIMEWAIT:
41070 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41071 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41072 counter[CM_DREQ_COUNTER]);
41073 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
41074 goto unlock;
41075 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
41076 cm_free_msg(msg);
41077 goto deref;
41078 case IB_CM_DREQ_RCVD:
41079 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41080 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41081 counter[CM_DREQ_COUNTER]);
41082 goto unlock;
41083 default:
41084 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
41085 ib_modify_mad(cm_id_priv->av.port->mad_agent,
41086 cm_id_priv->msg, timeout)) {
41087 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
41088 - atomic_long_inc(&work->port->
41089 + atomic_long_inc_unchecked(&work->port->
41090 counter_group[CM_RECV_DUPLICATES].
41091 counter[CM_MRA_COUNTER]);
41092 goto out;
41093 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
41094 break;
41095 case IB_CM_MRA_REQ_RCVD:
41096 case IB_CM_MRA_REP_RCVD:
41097 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41098 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41099 counter[CM_MRA_COUNTER]);
41100 /* fall through */
41101 default:
41102 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
41103 case IB_CM_LAP_IDLE:
41104 break;
41105 case IB_CM_MRA_LAP_SENT:
41106 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41107 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41108 counter[CM_LAP_COUNTER]);
41109 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
41110 goto unlock;
41111 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
41112 cm_free_msg(msg);
41113 goto deref;
41114 case IB_CM_LAP_RCVD:
41115 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41116 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41117 counter[CM_LAP_COUNTER]);
41118 goto unlock;
41119 default:
41120 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
41121 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
41122 if (cur_cm_id_priv) {
41123 spin_unlock_irq(&cm.lock);
41124 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41125 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41126 counter[CM_SIDR_REQ_COUNTER]);
41127 goto out; /* Duplicate message. */
41128 }
41129 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
41130 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
41131 msg->retries = 1;
41132
41133 - atomic_long_add(1 + msg->retries,
41134 + atomic_long_add_unchecked(1 + msg->retries,
41135 &port->counter_group[CM_XMIT].counter[attr_index]);
41136 if (msg->retries)
41137 - atomic_long_add(msg->retries,
41138 + atomic_long_add_unchecked(msg->retries,
41139 &port->counter_group[CM_XMIT_RETRIES].
41140 counter[attr_index]);
41141
41142 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
41143 }
41144
41145 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
41146 - atomic_long_inc(&port->counter_group[CM_RECV].
41147 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
41148 counter[attr_id - CM_ATTR_ID_OFFSET]);
41149
41150 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
41151 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
41152 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
41153
41154 return sprintf(buf, "%ld\n",
41155 - atomic_long_read(&group->counter[cm_attr->index]));
41156 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
41157 }
41158
41159 static const struct sysfs_ops cm_counter_ops = {
41160 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
41161 index 9f5ad7c..588cd84 100644
41162 --- a/drivers/infiniband/core/fmr_pool.c
41163 +++ b/drivers/infiniband/core/fmr_pool.c
41164 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
41165
41166 struct task_struct *thread;
41167
41168 - atomic_t req_ser;
41169 - atomic_t flush_ser;
41170 + atomic_unchecked_t req_ser;
41171 + atomic_unchecked_t flush_ser;
41172
41173 wait_queue_head_t force_wait;
41174 };
41175 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
41176 struct ib_fmr_pool *pool = pool_ptr;
41177
41178 do {
41179 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
41180 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
41181 ib_fmr_batch_release(pool);
41182
41183 - atomic_inc(&pool->flush_ser);
41184 + atomic_inc_unchecked(&pool->flush_ser);
41185 wake_up_interruptible(&pool->force_wait);
41186
41187 if (pool->flush_function)
41188 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
41189 }
41190
41191 set_current_state(TASK_INTERRUPTIBLE);
41192 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
41193 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
41194 !kthread_should_stop())
41195 schedule();
41196 __set_current_state(TASK_RUNNING);
41197 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
41198 pool->dirty_watermark = params->dirty_watermark;
41199 pool->dirty_len = 0;
41200 spin_lock_init(&pool->pool_lock);
41201 - atomic_set(&pool->req_ser, 0);
41202 - atomic_set(&pool->flush_ser, 0);
41203 + atomic_set_unchecked(&pool->req_ser, 0);
41204 + atomic_set_unchecked(&pool->flush_ser, 0);
41205 init_waitqueue_head(&pool->force_wait);
41206
41207 pool->thread = kthread_run(ib_fmr_cleanup_thread,
41208 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
41209 }
41210 spin_unlock_irq(&pool->pool_lock);
41211
41212 - serial = atomic_inc_return(&pool->req_ser);
41213 + serial = atomic_inc_return_unchecked(&pool->req_ser);
41214 wake_up_process(pool->thread);
41215
41216 if (wait_event_interruptible(pool->force_wait,
41217 - atomic_read(&pool->flush_ser) - serial >= 0))
41218 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
41219 return -EINTR;
41220
41221 return 0;
41222 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
41223 } else {
41224 list_add_tail(&fmr->list, &pool->dirty_list);
41225 if (++pool->dirty_len >= pool->dirty_watermark) {
41226 - atomic_inc(&pool->req_ser);
41227 + atomic_inc_unchecked(&pool->req_ser);
41228 wake_up_process(pool->thread);
41229 }
41230 }
41231 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
41232 index 4cb8eb2..146bf60 100644
41233 --- a/drivers/infiniband/hw/cxgb4/mem.c
41234 +++ b/drivers/infiniband/hw/cxgb4/mem.c
41235 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
41236 int err;
41237 struct fw_ri_tpte tpt;
41238 u32 stag_idx;
41239 - static atomic_t key;
41240 + static atomic_unchecked_t key;
41241
41242 if (c4iw_fatal_error(rdev))
41243 return -EIO;
41244 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
41245 if (rdev->stats.stag.cur > rdev->stats.stag.max)
41246 rdev->stats.stag.max = rdev->stats.stag.cur;
41247 mutex_unlock(&rdev->stats.lock);
41248 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
41249 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
41250 }
41251 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
41252 __func__, stag_state, type, pdid, stag_idx);
41253 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
41254 index 79b3dbc..96e5fcc 100644
41255 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
41256 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
41257 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
41258 struct ib_atomic_eth *ateth;
41259 struct ipath_ack_entry *e;
41260 u64 vaddr;
41261 - atomic64_t *maddr;
41262 + atomic64_unchecked_t *maddr;
41263 u64 sdata;
41264 u32 rkey;
41265 u8 next;
41266 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
41267 IB_ACCESS_REMOTE_ATOMIC)))
41268 goto nack_acc_unlck;
41269 /* Perform atomic OP and save result. */
41270 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
41271 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
41272 sdata = be64_to_cpu(ateth->swap_data);
41273 e = &qp->s_ack_queue[qp->r_head_ack_queue];
41274 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
41275 - (u64) atomic64_add_return(sdata, maddr) - sdata :
41276 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
41277 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
41278 be64_to_cpu(ateth->compare_data),
41279 sdata);
41280 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
41281 index 1f95bba..9530f87 100644
41282 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
41283 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
41284 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
41285 unsigned long flags;
41286 struct ib_wc wc;
41287 u64 sdata;
41288 - atomic64_t *maddr;
41289 + atomic64_unchecked_t *maddr;
41290 enum ib_wc_status send_status;
41291
41292 /*
41293 @@ -382,11 +382,11 @@ again:
41294 IB_ACCESS_REMOTE_ATOMIC)))
41295 goto acc_err;
41296 /* Perform atomic OP and save result. */
41297 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
41298 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
41299 sdata = wqe->wr.wr.atomic.compare_add;
41300 *(u64 *) sqp->s_sge.sge.vaddr =
41301 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
41302 - (u64) atomic64_add_return(sdata, maddr) - sdata :
41303 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
41304 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
41305 sdata, wqe->wr.wr.atomic.swap);
41306 goto send_comp;
41307 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
41308 index 4d599ce..697b17f 100644
41309 --- a/drivers/infiniband/hw/mlx4/mad.c
41310 +++ b/drivers/infiniband/hw/mlx4/mad.c
41311 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
41312
41313 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
41314 {
41315 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
41316 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
41317 cpu_to_be64(0xff00000000000000LL);
41318 }
41319
41320 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
41321 index f61ec26..ebf72cf 100644
41322 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
41323 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
41324 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
41325 struct list_head mcg_mgid0_list;
41326 struct workqueue_struct *mcg_wq;
41327 struct mlx4_ib_demux_pv_ctx **tun;
41328 - atomic_t tid;
41329 + atomic_unchecked_t tid;
41330 int flushing; /* flushing the work queue */
41331 };
41332
41333 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
41334 index 9d3e5c1..d9afe4a 100644
41335 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
41336 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
41337 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
41338 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
41339 }
41340
41341 -int mthca_QUERY_FW(struct mthca_dev *dev)
41342 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
41343 {
41344 struct mthca_mailbox *mailbox;
41345 u32 *outbox;
41346 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
41347 index ed9a989..e0c5871 100644
41348 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
41349 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
41350 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
41351 return key;
41352 }
41353
41354 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41355 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41356 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
41357 {
41358 struct mthca_mailbox *mailbox;
41359 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
41360 index 4291410..d2ab1fb 100644
41361 --- a/drivers/infiniband/hw/nes/nes.c
41362 +++ b/drivers/infiniband/hw/nes/nes.c
41363 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
41364 LIST_HEAD(nes_adapter_list);
41365 static LIST_HEAD(nes_dev_list);
41366
41367 -atomic_t qps_destroyed;
41368 +atomic_unchecked_t qps_destroyed;
41369
41370 static unsigned int ee_flsh_adapter;
41371 static unsigned int sysfs_nonidx_addr;
41372 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
41373 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
41374 struct nes_adapter *nesadapter = nesdev->nesadapter;
41375
41376 - atomic_inc(&qps_destroyed);
41377 + atomic_inc_unchecked(&qps_destroyed);
41378
41379 /* Free the control structures */
41380
41381 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
41382 index 33cc589..3bd6538 100644
41383 --- a/drivers/infiniband/hw/nes/nes.h
41384 +++ b/drivers/infiniband/hw/nes/nes.h
41385 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
41386 extern unsigned int wqm_quanta;
41387 extern struct list_head nes_adapter_list;
41388
41389 -extern atomic_t cm_connects;
41390 -extern atomic_t cm_accepts;
41391 -extern atomic_t cm_disconnects;
41392 -extern atomic_t cm_closes;
41393 -extern atomic_t cm_connecteds;
41394 -extern atomic_t cm_connect_reqs;
41395 -extern atomic_t cm_rejects;
41396 -extern atomic_t mod_qp_timouts;
41397 -extern atomic_t qps_created;
41398 -extern atomic_t qps_destroyed;
41399 -extern atomic_t sw_qps_destroyed;
41400 +extern atomic_unchecked_t cm_connects;
41401 +extern atomic_unchecked_t cm_accepts;
41402 +extern atomic_unchecked_t cm_disconnects;
41403 +extern atomic_unchecked_t cm_closes;
41404 +extern atomic_unchecked_t cm_connecteds;
41405 +extern atomic_unchecked_t cm_connect_reqs;
41406 +extern atomic_unchecked_t cm_rejects;
41407 +extern atomic_unchecked_t mod_qp_timouts;
41408 +extern atomic_unchecked_t qps_created;
41409 +extern atomic_unchecked_t qps_destroyed;
41410 +extern atomic_unchecked_t sw_qps_destroyed;
41411 extern u32 mh_detected;
41412 extern u32 mh_pauses_sent;
41413 extern u32 cm_packets_sent;
41414 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
41415 extern u32 cm_packets_received;
41416 extern u32 cm_packets_dropped;
41417 extern u32 cm_packets_retrans;
41418 -extern atomic_t cm_listens_created;
41419 -extern atomic_t cm_listens_destroyed;
41420 +extern atomic_unchecked_t cm_listens_created;
41421 +extern atomic_unchecked_t cm_listens_destroyed;
41422 extern u32 cm_backlog_drops;
41423 -extern atomic_t cm_loopbacks;
41424 -extern atomic_t cm_nodes_created;
41425 -extern atomic_t cm_nodes_destroyed;
41426 -extern atomic_t cm_accel_dropped_pkts;
41427 -extern atomic_t cm_resets_recvd;
41428 -extern atomic_t pau_qps_created;
41429 -extern atomic_t pau_qps_destroyed;
41430 +extern atomic_unchecked_t cm_loopbacks;
41431 +extern atomic_unchecked_t cm_nodes_created;
41432 +extern atomic_unchecked_t cm_nodes_destroyed;
41433 +extern atomic_unchecked_t cm_accel_dropped_pkts;
41434 +extern atomic_unchecked_t cm_resets_recvd;
41435 +extern atomic_unchecked_t pau_qps_created;
41436 +extern atomic_unchecked_t pau_qps_destroyed;
41437
41438 extern u32 int_mod_timer_init;
41439 extern u32 int_mod_cq_depth_256;
41440 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
41441 index 24b9f1a..00fd004 100644
41442 --- a/drivers/infiniband/hw/nes/nes_cm.c
41443 +++ b/drivers/infiniband/hw/nes/nes_cm.c
41444 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
41445 u32 cm_packets_retrans;
41446 u32 cm_packets_created;
41447 u32 cm_packets_received;
41448 -atomic_t cm_listens_created;
41449 -atomic_t cm_listens_destroyed;
41450 +atomic_unchecked_t cm_listens_created;
41451 +atomic_unchecked_t cm_listens_destroyed;
41452 u32 cm_backlog_drops;
41453 -atomic_t cm_loopbacks;
41454 -atomic_t cm_nodes_created;
41455 -atomic_t cm_nodes_destroyed;
41456 -atomic_t cm_accel_dropped_pkts;
41457 -atomic_t cm_resets_recvd;
41458 +atomic_unchecked_t cm_loopbacks;
41459 +atomic_unchecked_t cm_nodes_created;
41460 +atomic_unchecked_t cm_nodes_destroyed;
41461 +atomic_unchecked_t cm_accel_dropped_pkts;
41462 +atomic_unchecked_t cm_resets_recvd;
41463
41464 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
41465 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
41466 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
41467
41468 static struct nes_cm_core *g_cm_core;
41469
41470 -atomic_t cm_connects;
41471 -atomic_t cm_accepts;
41472 -atomic_t cm_disconnects;
41473 -atomic_t cm_closes;
41474 -atomic_t cm_connecteds;
41475 -atomic_t cm_connect_reqs;
41476 -atomic_t cm_rejects;
41477 +atomic_unchecked_t cm_connects;
41478 +atomic_unchecked_t cm_accepts;
41479 +atomic_unchecked_t cm_disconnects;
41480 +atomic_unchecked_t cm_closes;
41481 +atomic_unchecked_t cm_connecteds;
41482 +atomic_unchecked_t cm_connect_reqs;
41483 +atomic_unchecked_t cm_rejects;
41484
41485 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
41486 {
41487 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
41488 kfree(listener);
41489 listener = NULL;
41490 ret = 0;
41491 - atomic_inc(&cm_listens_destroyed);
41492 + atomic_inc_unchecked(&cm_listens_destroyed);
41493 } else {
41494 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
41495 }
41496 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
41497 cm_node->rem_mac);
41498
41499 add_hte_node(cm_core, cm_node);
41500 - atomic_inc(&cm_nodes_created);
41501 + atomic_inc_unchecked(&cm_nodes_created);
41502
41503 return cm_node;
41504 }
41505 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
41506 }
41507
41508 atomic_dec(&cm_core->node_cnt);
41509 - atomic_inc(&cm_nodes_destroyed);
41510 + atomic_inc_unchecked(&cm_nodes_destroyed);
41511 nesqp = cm_node->nesqp;
41512 if (nesqp) {
41513 nesqp->cm_node = NULL;
41514 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
41515
41516 static void drop_packet(struct sk_buff *skb)
41517 {
41518 - atomic_inc(&cm_accel_dropped_pkts);
41519 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41520 dev_kfree_skb_any(skb);
41521 }
41522
41523 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
41524 {
41525
41526 int reset = 0; /* whether to send reset in case of err.. */
41527 - atomic_inc(&cm_resets_recvd);
41528 + atomic_inc_unchecked(&cm_resets_recvd);
41529 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
41530 " refcnt=%d\n", cm_node, cm_node->state,
41531 atomic_read(&cm_node->ref_count));
41532 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
41533 rem_ref_cm_node(cm_node->cm_core, cm_node);
41534 return NULL;
41535 }
41536 - atomic_inc(&cm_loopbacks);
41537 + atomic_inc_unchecked(&cm_loopbacks);
41538 loopbackremotenode->loopbackpartner = cm_node;
41539 loopbackremotenode->tcp_cntxt.rcv_wscale =
41540 NES_CM_DEFAULT_RCV_WND_SCALE;
41541 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
41542 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
41543 else {
41544 rem_ref_cm_node(cm_core, cm_node);
41545 - atomic_inc(&cm_accel_dropped_pkts);
41546 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41547 dev_kfree_skb_any(skb);
41548 }
41549 break;
41550 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41551
41552 if ((cm_id) && (cm_id->event_handler)) {
41553 if (issue_disconn) {
41554 - atomic_inc(&cm_disconnects);
41555 + atomic_inc_unchecked(&cm_disconnects);
41556 cm_event.event = IW_CM_EVENT_DISCONNECT;
41557 cm_event.status = disconn_status;
41558 cm_event.local_addr = cm_id->local_addr;
41559 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41560 }
41561
41562 if (issue_close) {
41563 - atomic_inc(&cm_closes);
41564 + atomic_inc_unchecked(&cm_closes);
41565 nes_disconnect(nesqp, 1);
41566
41567 cm_id->provider_data = nesqp;
41568 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41569
41570 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
41571 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
41572 - atomic_inc(&cm_accepts);
41573 + atomic_inc_unchecked(&cm_accepts);
41574
41575 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
41576 netdev_refcnt_read(nesvnic->netdev));
41577 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
41578 struct nes_cm_core *cm_core;
41579 u8 *start_buff;
41580
41581 - atomic_inc(&cm_rejects);
41582 + atomic_inc_unchecked(&cm_rejects);
41583 cm_node = (struct nes_cm_node *)cm_id->provider_data;
41584 loopback = cm_node->loopbackpartner;
41585 cm_core = cm_node->cm_core;
41586 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41587 ntohl(cm_id->local_addr.sin_addr.s_addr),
41588 ntohs(cm_id->local_addr.sin_port));
41589
41590 - atomic_inc(&cm_connects);
41591 + atomic_inc_unchecked(&cm_connects);
41592 nesqp->active_conn = 1;
41593
41594 /* cache the cm_id in the qp */
41595 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
41596 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
41597 return err;
41598 }
41599 - atomic_inc(&cm_listens_created);
41600 + atomic_inc_unchecked(&cm_listens_created);
41601 }
41602
41603 cm_id->add_ref(cm_id);
41604 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
41605
41606 if (nesqp->destroyed)
41607 return;
41608 - atomic_inc(&cm_connecteds);
41609 + atomic_inc_unchecked(&cm_connecteds);
41610 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
41611 " local port 0x%04X. jiffies = %lu.\n",
41612 nesqp->hwqp.qp_id,
41613 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
41614
41615 cm_id->add_ref(cm_id);
41616 ret = cm_id->event_handler(cm_id, &cm_event);
41617 - atomic_inc(&cm_closes);
41618 + atomic_inc_unchecked(&cm_closes);
41619 cm_event.event = IW_CM_EVENT_CLOSE;
41620 cm_event.status = 0;
41621 cm_event.provider_data = cm_id->provider_data;
41622 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
41623 return;
41624 cm_id = cm_node->cm_id;
41625
41626 - atomic_inc(&cm_connect_reqs);
41627 + atomic_inc_unchecked(&cm_connect_reqs);
41628 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41629 cm_node, cm_id, jiffies);
41630
41631 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
41632 return;
41633 cm_id = cm_node->cm_id;
41634
41635 - atomic_inc(&cm_connect_reqs);
41636 + atomic_inc_unchecked(&cm_connect_reqs);
41637 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41638 cm_node, cm_id, jiffies);
41639
41640 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
41641 index 4166452..fc952c3 100644
41642 --- a/drivers/infiniband/hw/nes/nes_mgt.c
41643 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
41644 @@ -40,8 +40,8 @@
41645 #include "nes.h"
41646 #include "nes_mgt.h"
41647
41648 -atomic_t pau_qps_created;
41649 -atomic_t pau_qps_destroyed;
41650 +atomic_unchecked_t pau_qps_created;
41651 +atomic_unchecked_t pau_qps_destroyed;
41652
41653 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
41654 {
41655 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
41656 {
41657 struct sk_buff *skb;
41658 unsigned long flags;
41659 - atomic_inc(&pau_qps_destroyed);
41660 + atomic_inc_unchecked(&pau_qps_destroyed);
41661
41662 /* Free packets that have not yet been forwarded */
41663 /* Lock is acquired by skb_dequeue when removing the skb */
41664 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
41665 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
41666 skb_queue_head_init(&nesqp->pau_list);
41667 spin_lock_init(&nesqp->pau_lock);
41668 - atomic_inc(&pau_qps_created);
41669 + atomic_inc_unchecked(&pau_qps_created);
41670 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
41671 }
41672
41673 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
41674 index 49eb511..a774366 100644
41675 --- a/drivers/infiniband/hw/nes/nes_nic.c
41676 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41677 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41678 target_stat_values[++index] = mh_detected;
41679 target_stat_values[++index] = mh_pauses_sent;
41680 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41681 - target_stat_values[++index] = atomic_read(&cm_connects);
41682 - target_stat_values[++index] = atomic_read(&cm_accepts);
41683 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41684 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41685 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41686 - target_stat_values[++index] = atomic_read(&cm_rejects);
41687 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41688 - target_stat_values[++index] = atomic_read(&qps_created);
41689 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41690 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41691 - target_stat_values[++index] = atomic_read(&cm_closes);
41692 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41693 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41694 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41695 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41696 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41697 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41698 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41699 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41700 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41701 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41702 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41703 target_stat_values[++index] = cm_packets_sent;
41704 target_stat_values[++index] = cm_packets_bounced;
41705 target_stat_values[++index] = cm_packets_created;
41706 target_stat_values[++index] = cm_packets_received;
41707 target_stat_values[++index] = cm_packets_dropped;
41708 target_stat_values[++index] = cm_packets_retrans;
41709 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41710 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41711 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41712 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41713 target_stat_values[++index] = cm_backlog_drops;
41714 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41715 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41716 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41717 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41718 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41719 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41720 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41721 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41722 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41723 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41724 target_stat_values[++index] = nesadapter->free_4kpbl;
41725 target_stat_values[++index] = nesadapter->free_256pbl;
41726 target_stat_values[++index] = int_mod_timer_init;
41727 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41728 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41729 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41730 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41731 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41732 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41733 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41734 }
41735
41736 /**
41737 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41738 index 8f67fe2..8960859 100644
41739 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41740 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41741 @@ -46,9 +46,9 @@
41742
41743 #include <rdma/ib_umem.h>
41744
41745 -atomic_t mod_qp_timouts;
41746 -atomic_t qps_created;
41747 -atomic_t sw_qps_destroyed;
41748 +atomic_unchecked_t mod_qp_timouts;
41749 +atomic_unchecked_t qps_created;
41750 +atomic_unchecked_t sw_qps_destroyed;
41751
41752 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41753
41754 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41755 if (init_attr->create_flags)
41756 return ERR_PTR(-EINVAL);
41757
41758 - atomic_inc(&qps_created);
41759 + atomic_inc_unchecked(&qps_created);
41760 switch (init_attr->qp_type) {
41761 case IB_QPT_RC:
41762 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41763 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41764 struct iw_cm_event cm_event;
41765 int ret = 0;
41766
41767 - atomic_inc(&sw_qps_destroyed);
41768 + atomic_inc_unchecked(&sw_qps_destroyed);
41769 nesqp->destroyed = 1;
41770
41771 /* Blow away the connection if it exists. */
41772 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41773 index 4d11575..3e890e5 100644
41774 --- a/drivers/infiniband/hw/qib/qib.h
41775 +++ b/drivers/infiniband/hw/qib/qib.h
41776 @@ -51,6 +51,7 @@
41777 #include <linux/completion.h>
41778 #include <linux/kref.h>
41779 #include <linux/sched.h>
41780 +#include <linux/slab.h>
41781
41782 #include "qib_common.h"
41783 #include "qib_verbs.h"
41784 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41785 index da739d9..da1c7f4 100644
41786 --- a/drivers/input/gameport/gameport.c
41787 +++ b/drivers/input/gameport/gameport.c
41788 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41789 */
41790 static void gameport_init_port(struct gameport *gameport)
41791 {
41792 - static atomic_t gameport_no = ATOMIC_INIT(0);
41793 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41794
41795 __module_get(THIS_MODULE);
41796
41797 mutex_init(&gameport->drv_mutex);
41798 device_initialize(&gameport->dev);
41799 dev_set_name(&gameport->dev, "gameport%lu",
41800 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41801 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41802 gameport->dev.bus = &gameport_bus;
41803 gameport->dev.release = gameport_release_port;
41804 if (gameport->parent)
41805 diff --git a/drivers/input/input.c b/drivers/input/input.c
41806 index c044699..174d71a 100644
41807 --- a/drivers/input/input.c
41808 +++ b/drivers/input/input.c
41809 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
41810 */
41811 int input_register_device(struct input_dev *dev)
41812 {
41813 - static atomic_t input_no = ATOMIC_INIT(0);
41814 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41815 struct input_devres *devres = NULL;
41816 struct input_handler *handler;
41817 unsigned int packet_size;
41818 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
41819 dev->setkeycode = input_default_setkeycode;
41820
41821 dev_set_name(&dev->dev, "input%ld",
41822 - (unsigned long) atomic_inc_return(&input_no) - 1);
41823 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41824
41825 error = device_add(&dev->dev);
41826 if (error)
41827 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41828 index 04c69af..5f92d00 100644
41829 --- a/drivers/input/joystick/sidewinder.c
41830 +++ b/drivers/input/joystick/sidewinder.c
41831 @@ -30,6 +30,7 @@
41832 #include <linux/kernel.h>
41833 #include <linux/module.h>
41834 #include <linux/slab.h>
41835 +#include <linux/sched.h>
41836 #include <linux/init.h>
41837 #include <linux/input.h>
41838 #include <linux/gameport.h>
41839 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41840 index fa061d4..4a6957c 100644
41841 --- a/drivers/input/joystick/xpad.c
41842 +++ b/drivers/input/joystick/xpad.c
41843 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41844
41845 static int xpad_led_probe(struct usb_xpad *xpad)
41846 {
41847 - static atomic_t led_seq = ATOMIC_INIT(0);
41848 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41849 long led_no;
41850 struct xpad_led *led;
41851 struct led_classdev *led_cdev;
41852 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41853 if (!led)
41854 return -ENOMEM;
41855
41856 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41857 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41858
41859 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41860 led->xpad = xpad;
41861 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41862 index e204f26..8459f15 100644
41863 --- a/drivers/input/misc/ims-pcu.c
41864 +++ b/drivers/input/misc/ims-pcu.c
41865 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41866
41867 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41868 {
41869 - static atomic_t device_no = ATOMIC_INIT(0);
41870 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41871
41872 const struct ims_pcu_device_info *info;
41873 u8 device_id;
41874 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41875 }
41876
41877 /* Device appears to be operable, complete initialization */
41878 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41879 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41880
41881 error = ims_pcu_setup_backlight(pcu);
41882 if (error)
41883 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41884 index 2f0b39d..7370f13 100644
41885 --- a/drivers/input/mouse/psmouse.h
41886 +++ b/drivers/input/mouse/psmouse.h
41887 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41888 ssize_t (*set)(struct psmouse *psmouse, void *data,
41889 const char *buf, size_t count);
41890 bool protect;
41891 -};
41892 +} __do_const;
41893 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41894
41895 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41896 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41897 index 4c842c3..590b0bf 100644
41898 --- a/drivers/input/mousedev.c
41899 +++ b/drivers/input/mousedev.c
41900 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41901
41902 spin_unlock_irq(&client->packet_lock);
41903
41904 - if (copy_to_user(buffer, data, count))
41905 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41906 return -EFAULT;
41907
41908 return count;
41909 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41910 index 25fc597..558bf3b3 100644
41911 --- a/drivers/input/serio/serio.c
41912 +++ b/drivers/input/serio/serio.c
41913 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41914 */
41915 static void serio_init_port(struct serio *serio)
41916 {
41917 - static atomic_t serio_no = ATOMIC_INIT(0);
41918 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41919
41920 __module_get(THIS_MODULE);
41921
41922 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41923 mutex_init(&serio->drv_mutex);
41924 device_initialize(&serio->dev);
41925 dev_set_name(&serio->dev, "serio%ld",
41926 - (long)atomic_inc_return(&serio_no) - 1);
41927 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41928 serio->dev.bus = &serio_bus;
41929 serio->dev.release = serio_release_port;
41930 serio->dev.groups = serio_device_attr_groups;
41931 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41932 index 59df2e7..8f1cafb 100644
41933 --- a/drivers/input/serio/serio_raw.c
41934 +++ b/drivers/input/serio/serio_raw.c
41935 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41936
41937 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41938 {
41939 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41940 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41941 struct serio_raw *serio_raw;
41942 int err;
41943
41944 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41945 }
41946
41947 snprintf(serio_raw->name, sizeof(serio_raw->name),
41948 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41949 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41950 kref_init(&serio_raw->kref);
41951 INIT_LIST_HEAD(&serio_raw->client_list);
41952 init_waitqueue_head(&serio_raw->wait);
41953 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41954 index d8f98b1..f62a640 100644
41955 --- a/drivers/iommu/iommu.c
41956 +++ b/drivers/iommu/iommu.c
41957 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41958 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41959 {
41960 bus_register_notifier(bus, &iommu_bus_nb);
41961 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41962 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41963 }
41964
41965 /**
41966 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41967 index dcfea4e..f4226b2 100644
41968 --- a/drivers/iommu/irq_remapping.c
41969 +++ b/drivers/iommu/irq_remapping.c
41970 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41971 void panic_if_irq_remap(const char *msg)
41972 {
41973 if (irq_remapping_enabled)
41974 - panic(msg);
41975 + panic("%s", msg);
41976 }
41977
41978 static void ir_ack_apic_edge(struct irq_data *data)
41979 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41980
41981 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41982 {
41983 - chip->irq_print_chip = ir_print_prefix;
41984 - chip->irq_ack = ir_ack_apic_edge;
41985 - chip->irq_eoi = ir_ack_apic_level;
41986 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41987 + pax_open_kernel();
41988 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41989 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41990 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41991 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41992 + pax_close_kernel();
41993 }
41994
41995 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41996 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41997 index 19ceaa6..3625818 100644
41998 --- a/drivers/irqchip/irq-gic.c
41999 +++ b/drivers/irqchip/irq-gic.c
42000 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
42001 * Supported arch specific GIC irq extension.
42002 * Default make them NULL.
42003 */
42004 -struct irq_chip gic_arch_extn = {
42005 +irq_chip_no_const gic_arch_extn = {
42006 .irq_eoi = NULL,
42007 .irq_mask = NULL,
42008 .irq_unmask = NULL,
42009 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
42010 chained_irq_exit(chip, desc);
42011 }
42012
42013 -static struct irq_chip gic_chip = {
42014 +static irq_chip_no_const gic_chip __read_only = {
42015 .name = "GIC",
42016 .irq_mask = gic_mask_irq,
42017 .irq_unmask = gic_unmask_irq,
42018 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
42019 index ac6f72b..81150f2 100644
42020 --- a/drivers/isdn/capi/capi.c
42021 +++ b/drivers/isdn/capi/capi.c
42022 @@ -81,8 +81,8 @@ struct capiminor {
42023
42024 struct capi20_appl *ap;
42025 u32 ncci;
42026 - atomic_t datahandle;
42027 - atomic_t msgid;
42028 + atomic_unchecked_t datahandle;
42029 + atomic_unchecked_t msgid;
42030
42031 struct tty_port port;
42032 int ttyinstop;
42033 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
42034 capimsg_setu16(s, 2, mp->ap->applid);
42035 capimsg_setu8 (s, 4, CAPI_DATA_B3);
42036 capimsg_setu8 (s, 5, CAPI_RESP);
42037 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
42038 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
42039 capimsg_setu32(s, 8, mp->ncci);
42040 capimsg_setu16(s, 12, datahandle);
42041 }
42042 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
42043 mp->outbytes -= len;
42044 spin_unlock_bh(&mp->outlock);
42045
42046 - datahandle = atomic_inc_return(&mp->datahandle);
42047 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
42048 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
42049 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
42050 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
42051 capimsg_setu16(skb->data, 2, mp->ap->applid);
42052 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
42053 capimsg_setu8 (skb->data, 5, CAPI_REQ);
42054 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
42055 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
42056 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
42057 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
42058 capimsg_setu16(skb->data, 16, len); /* Data length */
42059 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
42060 index 600c79b..3752bab 100644
42061 --- a/drivers/isdn/gigaset/interface.c
42062 +++ b/drivers/isdn/gigaset/interface.c
42063 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
42064 }
42065 tty->driver_data = cs;
42066
42067 - ++cs->port.count;
42068 + atomic_inc(&cs->port.count);
42069
42070 - if (cs->port.count == 1) {
42071 + if (atomic_read(&cs->port.count) == 1) {
42072 tty_port_tty_set(&cs->port, tty);
42073 cs->port.low_latency = 1;
42074 }
42075 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
42076
42077 if (!cs->connected)
42078 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
42079 - else if (!cs->port.count)
42080 + else if (!atomic_read(&cs->port.count))
42081 dev_warn(cs->dev, "%s: device not opened\n", __func__);
42082 - else if (!--cs->port.count)
42083 + else if (!atomic_dec_return(&cs->port.count))
42084 tty_port_tty_set(&cs->port, NULL);
42085
42086 mutex_unlock(&cs->mutex);
42087 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
42088 index d0a41cb..f0cdb8c 100644
42089 --- a/drivers/isdn/gigaset/usb-gigaset.c
42090 +++ b/drivers/isdn/gigaset/usb-gigaset.c
42091 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
42092 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
42093 memcpy(cs->hw.usb->bchars, buf, 6);
42094 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
42095 - 0, 0, &buf, 6, 2000);
42096 + 0, 0, buf, 6, 2000);
42097 }
42098
42099 static void gigaset_freebcshw(struct bc_state *bcs)
42100 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
42101 index 4d9b195..455075c 100644
42102 --- a/drivers/isdn/hardware/avm/b1.c
42103 +++ b/drivers/isdn/hardware/avm/b1.c
42104 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
42105 }
42106 if (left) {
42107 if (t4file->user) {
42108 - if (copy_from_user(buf, dp, left))
42109 + if (left > sizeof buf || copy_from_user(buf, dp, left))
42110 return -EFAULT;
42111 } else {
42112 memcpy(buf, dp, left);
42113 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
42114 }
42115 if (left) {
42116 if (config->user) {
42117 - if (copy_from_user(buf, dp, left))
42118 + if (left > sizeof buf || copy_from_user(buf, dp, left))
42119 return -EFAULT;
42120 } else {
42121 memcpy(buf, dp, left);
42122 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
42123 index 9bb12ba..d4262f7 100644
42124 --- a/drivers/isdn/i4l/isdn_common.c
42125 +++ b/drivers/isdn/i4l/isdn_common.c
42126 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
42127 } else
42128 return -EINVAL;
42129 case IIOCDBGVAR:
42130 + if (!capable(CAP_SYS_RAWIO))
42131 + return -EPERM;
42132 if (arg) {
42133 if (copy_to_user(argp, &dev, sizeof(ulong)))
42134 return -EFAULT;
42135 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
42136 index 3c5f249..5fac4d0 100644
42137 --- a/drivers/isdn/i4l/isdn_tty.c
42138 +++ b/drivers/isdn/i4l/isdn_tty.c
42139 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
42140
42141 #ifdef ISDN_DEBUG_MODEM_OPEN
42142 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
42143 - port->count);
42144 + atomic_read(&port->count));
42145 #endif
42146 - port->count++;
42147 + atomic_inc(&port->count);
42148 port->tty = tty;
42149 /*
42150 * Start up serial port
42151 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42152 #endif
42153 return;
42154 }
42155 - if ((tty->count == 1) && (port->count != 1)) {
42156 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
42157 /*
42158 * Uh, oh. tty->count is 1, which means that the tty
42159 * structure will be freed. Info->count should always
42160 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42161 * serial port won't be shutdown.
42162 */
42163 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
42164 - "info->count is %d\n", port->count);
42165 - port->count = 1;
42166 + "info->count is %d\n", atomic_read(&port->count));
42167 + atomic_set(&port->count, 1);
42168 }
42169 - if (--port->count < 0) {
42170 + if (atomic_dec_return(&port->count) < 0) {
42171 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
42172 - info->line, port->count);
42173 - port->count = 0;
42174 + info->line, atomic_read(&port->count));
42175 + atomic_set(&port->count, 0);
42176 }
42177 - if (port->count) {
42178 + if (atomic_read(&port->count)) {
42179 #ifdef ISDN_DEBUG_MODEM_OPEN
42180 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
42181 #endif
42182 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
42183 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
42184 return;
42185 isdn_tty_shutdown(info);
42186 - port->count = 0;
42187 + atomic_set(&port->count, 0);
42188 port->flags &= ~ASYNC_NORMAL_ACTIVE;
42189 port->tty = NULL;
42190 wake_up_interruptible(&port->open_wait);
42191 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
42192 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
42193 modem_info *info = &dev->mdm.info[i];
42194
42195 - if (info->port.count == 0)
42196 + if (atomic_read(&info->port.count) == 0)
42197 continue;
42198 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
42199 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
42200 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
42201 index e74df7c..03a03ba 100644
42202 --- a/drivers/isdn/icn/icn.c
42203 +++ b/drivers/isdn/icn/icn.c
42204 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
42205 if (count > len)
42206 count = len;
42207 if (user) {
42208 - if (copy_from_user(msg, buf, count))
42209 + if (count > sizeof msg || copy_from_user(msg, buf, count))
42210 return -EFAULT;
42211 } else
42212 memcpy(msg, buf, count);
42213 diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
42214 index 22b720e..77025f5 100644
42215 --- a/drivers/isdn/mISDN/dsp_core.c
42216 +++ b/drivers/isdn/mISDN/dsp_core.c
42217 @@ -288,8 +288,10 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
42218 u8 *data;
42219 int len;
42220
42221 - if (skb->len < sizeof(int))
42222 + if (skb->len < sizeof(int)) {
42223 printk(KERN_ERR "%s: PH_CONTROL message too short\n", __func__);
42224 + return -EINVAL;
42225 + }
42226 cont = *((int *)skb->data);
42227 len = skb->len - sizeof(int);
42228 data = skb->data + sizeof(int);
42229 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
42230 index 6a8405d..0bd1c7e 100644
42231 --- a/drivers/leds/leds-clevo-mail.c
42232 +++ b/drivers/leds/leds-clevo-mail.c
42233 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
42234 * detected as working, but in reality it is not) as low as
42235 * possible.
42236 */
42237 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
42238 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
42239 {
42240 .callback = clevo_mail_led_dmi_callback,
42241 .ident = "Clevo D410J",
42242 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
42243 index 64e204e..c6bf189 100644
42244 --- a/drivers/leds/leds-ss4200.c
42245 +++ b/drivers/leds/leds-ss4200.c
42246 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
42247 * detected as working, but in reality it is not) as low as
42248 * possible.
42249 */
42250 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
42251 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
42252 {
42253 .callback = ss4200_led_dmi_callback,
42254 .ident = "Intel SS4200-E",
42255 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
42256 index 0bf1e4e..b4bf44e 100644
42257 --- a/drivers/lguest/core.c
42258 +++ b/drivers/lguest/core.c
42259 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
42260 * The end address needs +1 because __get_vm_area allocates an
42261 * extra guard page, so we need space for that.
42262 */
42263 +
42264 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
42265 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42266 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
42267 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42268 +#else
42269 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42270 VM_ALLOC, switcher_addr, switcher_addr
42271 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42272 +#endif
42273 +
42274 if (!switcher_vma) {
42275 err = -ENOMEM;
42276 printk("lguest: could not map switcher pages high\n");
42277 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
42278 * Now the Switcher is mapped at the right address, we can't fail!
42279 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
42280 */
42281 - memcpy(switcher_vma->addr, start_switcher_text,
42282 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42283 end_switcher_text - start_switcher_text);
42284
42285 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42286 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42287 index 5b9ac32..2ef4f26 100644
42288 --- a/drivers/lguest/page_tables.c
42289 +++ b/drivers/lguest/page_tables.c
42290 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42291 /*:*/
42292
42293 #ifdef CONFIG_X86_PAE
42294 -static void release_pmd(pmd_t *spmd)
42295 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42296 {
42297 /* If the entry's not present, there's nothing to release. */
42298 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42299 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42300 index f0a3347..f6608b2 100644
42301 --- a/drivers/lguest/x86/core.c
42302 +++ b/drivers/lguest/x86/core.c
42303 @@ -59,7 +59,7 @@ static struct {
42304 /* Offset from where switcher.S was compiled to where we've copied it */
42305 static unsigned long switcher_offset(void)
42306 {
42307 - return switcher_addr - (unsigned long)start_switcher_text;
42308 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42309 }
42310
42311 /* This cpu's struct lguest_pages (after the Switcher text page) */
42312 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42313 * These copies are pretty cheap, so we do them unconditionally: */
42314 /* Save the current Host top-level page directory.
42315 */
42316 +
42317 +#ifdef CONFIG_PAX_PER_CPU_PGD
42318 + pages->state.host_cr3 = read_cr3();
42319 +#else
42320 pages->state.host_cr3 = __pa(current->mm->pgd);
42321 +#endif
42322 +
42323 /*
42324 * Set up the Guest's page tables to see this CPU's pages (and no
42325 * other CPU's pages).
42326 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42327 * compiled-in switcher code and the high-mapped copy we just made.
42328 */
42329 for (i = 0; i < IDT_ENTRIES; i++)
42330 - default_idt_entries[i] += switcher_offset();
42331 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42332
42333 /*
42334 * Set up the Switcher's per-cpu areas.
42335 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42336 * it will be undisturbed when we switch. To change %cs and jump we
42337 * need this structure to feed to Intel's "lcall" instruction.
42338 */
42339 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42340 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42341 lguest_entry.segment = LGUEST_CS;
42342
42343 /*
42344 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42345 index 40634b0..4f5855e 100644
42346 --- a/drivers/lguest/x86/switcher_32.S
42347 +++ b/drivers/lguest/x86/switcher_32.S
42348 @@ -87,6 +87,7 @@
42349 #include <asm/page.h>
42350 #include <asm/segment.h>
42351 #include <asm/lguest.h>
42352 +#include <asm/processor-flags.h>
42353
42354 // We mark the start of the code to copy
42355 // It's placed in .text tho it's never run here
42356 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42357 // Changes type when we load it: damn Intel!
42358 // For after we switch over our page tables
42359 // That entry will be read-only: we'd crash.
42360 +
42361 +#ifdef CONFIG_PAX_KERNEXEC
42362 + mov %cr0, %edx
42363 + xor $X86_CR0_WP, %edx
42364 + mov %edx, %cr0
42365 +#endif
42366 +
42367 movl $(GDT_ENTRY_TSS*8), %edx
42368 ltr %dx
42369
42370 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42371 // Let's clear it again for our return.
42372 // The GDT descriptor of the Host
42373 // Points to the table after two "size" bytes
42374 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42375 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42376 // Clear "used" from type field (byte 5, bit 2)
42377 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42378 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42379 +
42380 +#ifdef CONFIG_PAX_KERNEXEC
42381 + mov %cr0, %eax
42382 + xor $X86_CR0_WP, %eax
42383 + mov %eax, %cr0
42384 +#endif
42385
42386 // Once our page table's switched, the Guest is live!
42387 // The Host fades as we run this final step.
42388 @@ -295,13 +309,12 @@ deliver_to_host:
42389 // I consulted gcc, and it gave
42390 // These instructions, which I gladly credit:
42391 leal (%edx,%ebx,8), %eax
42392 - movzwl (%eax),%edx
42393 - movl 4(%eax), %eax
42394 - xorw %ax, %ax
42395 - orl %eax, %edx
42396 + movl 4(%eax), %edx
42397 + movw (%eax), %dx
42398 // Now the address of the handler's in %edx
42399 // We call it now: its "iret" drops us home.
42400 - jmp *%edx
42401 + ljmp $__KERNEL_CS, $1f
42402 +1: jmp *%edx
42403
42404 // Every interrupt can come to us here
42405 // But we must truly tell each apart.
42406 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42407 index 0003992..854bbce 100644
42408 --- a/drivers/md/bcache/closure.h
42409 +++ b/drivers/md/bcache/closure.h
42410 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42411 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42412 struct workqueue_struct *wq)
42413 {
42414 - BUG_ON(object_is_on_stack(cl));
42415 + BUG_ON(object_starts_on_stack(cl));
42416 closure_set_ip(cl);
42417 cl->fn = fn;
42418 cl->wq = wq;
42419 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42420 index b4713ce..b30139b 100644
42421 --- a/drivers/md/bcache/super.c
42422 +++ b/drivers/md/bcache/super.c
42423 @@ -1603,7 +1603,7 @@ err_unlock_gc:
42424 err:
42425 closure_sync(&op.cl);
42426 /* XXX: test this, it's broken */
42427 - bch_cache_set_error(c, err);
42428 + bch_cache_set_error(c, "%s", err);
42429 }
42430
42431 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42432 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42433 index 5a2c754..0fa55db 100644
42434 --- a/drivers/md/bitmap.c
42435 +++ b/drivers/md/bitmap.c
42436 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42437 chunk_kb ? "KB" : "B");
42438 if (bitmap->storage.file) {
42439 seq_printf(seq, ", file: ");
42440 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42441 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42442 }
42443
42444 seq_printf(seq, "\n");
42445 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42446 index 81a79b7..87a0f73 100644
42447 --- a/drivers/md/dm-ioctl.c
42448 +++ b/drivers/md/dm-ioctl.c
42449 @@ -1697,7 +1697,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42450 cmd == DM_LIST_VERSIONS_CMD)
42451 return 0;
42452
42453 - if ((cmd == DM_DEV_CREATE_CMD)) {
42454 + if (cmd == DM_DEV_CREATE_CMD) {
42455 if (!*param->name) {
42456 DMWARN("name not supplied when creating device");
42457 return -EINVAL;
42458 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42459 index 699b5be..eac0a15 100644
42460 --- a/drivers/md/dm-raid1.c
42461 +++ b/drivers/md/dm-raid1.c
42462 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42463
42464 struct mirror {
42465 struct mirror_set *ms;
42466 - atomic_t error_count;
42467 + atomic_unchecked_t error_count;
42468 unsigned long error_type;
42469 struct dm_dev *dev;
42470 sector_t offset;
42471 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42472 struct mirror *m;
42473
42474 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42475 - if (!atomic_read(&m->error_count))
42476 + if (!atomic_read_unchecked(&m->error_count))
42477 return m;
42478
42479 return NULL;
42480 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42481 * simple way to tell if a device has encountered
42482 * errors.
42483 */
42484 - atomic_inc(&m->error_count);
42485 + atomic_inc_unchecked(&m->error_count);
42486
42487 if (test_and_set_bit(error_type, &m->error_type))
42488 return;
42489 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42490 struct mirror *m = get_default_mirror(ms);
42491
42492 do {
42493 - if (likely(!atomic_read(&m->error_count)))
42494 + if (likely(!atomic_read_unchecked(&m->error_count)))
42495 return m;
42496
42497 if (m-- == ms->mirror)
42498 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42499 {
42500 struct mirror *default_mirror = get_default_mirror(m->ms);
42501
42502 - return !atomic_read(&default_mirror->error_count);
42503 + return !atomic_read_unchecked(&default_mirror->error_count);
42504 }
42505
42506 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42507 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42508 */
42509 if (likely(region_in_sync(ms, region, 1)))
42510 m = choose_mirror(ms, bio->bi_sector);
42511 - else if (m && atomic_read(&m->error_count))
42512 + else if (m && atomic_read_unchecked(&m->error_count))
42513 m = NULL;
42514
42515 if (likely(m))
42516 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42517 }
42518
42519 ms->mirror[mirror].ms = ms;
42520 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42521 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42522 ms->mirror[mirror].error_type = 0;
42523 ms->mirror[mirror].offset = offset;
42524
42525 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42526 */
42527 static char device_status_char(struct mirror *m)
42528 {
42529 - if (!atomic_read(&(m->error_count)))
42530 + if (!atomic_read_unchecked(&(m->error_count)))
42531 return 'A';
42532
42533 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42534 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42535 index d907ca6..cfb8384 100644
42536 --- a/drivers/md/dm-stripe.c
42537 +++ b/drivers/md/dm-stripe.c
42538 @@ -20,7 +20,7 @@ struct stripe {
42539 struct dm_dev *dev;
42540 sector_t physical_start;
42541
42542 - atomic_t error_count;
42543 + atomic_unchecked_t error_count;
42544 };
42545
42546 struct stripe_c {
42547 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42548 kfree(sc);
42549 return r;
42550 }
42551 - atomic_set(&(sc->stripe[i].error_count), 0);
42552 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42553 }
42554
42555 ti->private = sc;
42556 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42557 DMEMIT("%d ", sc->stripes);
42558 for (i = 0; i < sc->stripes; i++) {
42559 DMEMIT("%s ", sc->stripe[i].dev->name);
42560 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42561 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42562 'D' : 'A';
42563 }
42564 buffer[i] = '\0';
42565 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42566 */
42567 for (i = 0; i < sc->stripes; i++)
42568 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42569 - atomic_inc(&(sc->stripe[i].error_count));
42570 - if (atomic_read(&(sc->stripe[i].error_count)) <
42571 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42572 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42573 DM_IO_ERROR_THRESHOLD)
42574 schedule_work(&sc->trigger_event);
42575 }
42576 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42577 index 1ff252a..ee384c1 100644
42578 --- a/drivers/md/dm-table.c
42579 +++ b/drivers/md/dm-table.c
42580 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42581 if (!dev_size)
42582 return 0;
42583
42584 - if ((start >= dev_size) || (start + len > dev_size)) {
42585 + if ((start >= dev_size) || (len > dev_size - start)) {
42586 DMWARN("%s: %s too small for target: "
42587 "start=%llu, len=%llu, dev_size=%llu",
42588 dm_device_name(ti->table->md), bdevname(bdev, b),
42589 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42590 index 60bce43..9b997d0 100644
42591 --- a/drivers/md/dm-thin-metadata.c
42592 +++ b/drivers/md/dm-thin-metadata.c
42593 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42594 {
42595 pmd->info.tm = pmd->tm;
42596 pmd->info.levels = 2;
42597 - pmd->info.value_type.context = pmd->data_sm;
42598 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42599 pmd->info.value_type.size = sizeof(__le64);
42600 pmd->info.value_type.inc = data_block_inc;
42601 pmd->info.value_type.dec = data_block_dec;
42602 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42603
42604 pmd->bl_info.tm = pmd->tm;
42605 pmd->bl_info.levels = 1;
42606 - pmd->bl_info.value_type.context = pmd->data_sm;
42607 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42608 pmd->bl_info.value_type.size = sizeof(__le64);
42609 pmd->bl_info.value_type.inc = data_block_inc;
42610 pmd->bl_info.value_type.dec = data_block_dec;
42611 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42612 index 33f2010..23fb84c 100644
42613 --- a/drivers/md/dm.c
42614 +++ b/drivers/md/dm.c
42615 @@ -169,9 +169,9 @@ struct mapped_device {
42616 /*
42617 * Event handling.
42618 */
42619 - atomic_t event_nr;
42620 + atomic_unchecked_t event_nr;
42621 wait_queue_head_t eventq;
42622 - atomic_t uevent_seq;
42623 + atomic_unchecked_t uevent_seq;
42624 struct list_head uevent_list;
42625 spinlock_t uevent_lock; /* Protect access to uevent_list */
42626
42627 @@ -1884,8 +1884,8 @@ static struct mapped_device *alloc_dev(int minor)
42628 rwlock_init(&md->map_lock);
42629 atomic_set(&md->holders, 1);
42630 atomic_set(&md->open_count, 0);
42631 - atomic_set(&md->event_nr, 0);
42632 - atomic_set(&md->uevent_seq, 0);
42633 + atomic_set_unchecked(&md->event_nr, 0);
42634 + atomic_set_unchecked(&md->uevent_seq, 0);
42635 INIT_LIST_HEAD(&md->uevent_list);
42636 spin_lock_init(&md->uevent_lock);
42637
42638 @@ -2033,7 +2033,7 @@ static void event_callback(void *context)
42639
42640 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42641
42642 - atomic_inc(&md->event_nr);
42643 + atomic_inc_unchecked(&md->event_nr);
42644 wake_up(&md->eventq);
42645 }
42646
42647 @@ -2690,18 +2690,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42648
42649 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42650 {
42651 - return atomic_add_return(1, &md->uevent_seq);
42652 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42653 }
42654
42655 uint32_t dm_get_event_nr(struct mapped_device *md)
42656 {
42657 - return atomic_read(&md->event_nr);
42658 + return atomic_read_unchecked(&md->event_nr);
42659 }
42660
42661 int dm_wait_event(struct mapped_device *md, int event_nr)
42662 {
42663 return wait_event_interruptible(md->eventq,
42664 - (event_nr != atomic_read(&md->event_nr)));
42665 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42666 }
42667
42668 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42669 diff --git a/drivers/md/md.c b/drivers/md/md.c
42670 index 51f0345..c77810e 100644
42671 --- a/drivers/md/md.c
42672 +++ b/drivers/md/md.c
42673 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42674 * start build, activate spare
42675 */
42676 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42677 -static atomic_t md_event_count;
42678 +static atomic_unchecked_t md_event_count;
42679 void md_new_event(struct mddev *mddev)
42680 {
42681 - atomic_inc(&md_event_count);
42682 + atomic_inc_unchecked(&md_event_count);
42683 wake_up(&md_event_waiters);
42684 }
42685 EXPORT_SYMBOL_GPL(md_new_event);
42686 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42687 */
42688 static void md_new_event_inintr(struct mddev *mddev)
42689 {
42690 - atomic_inc(&md_event_count);
42691 + atomic_inc_unchecked(&md_event_count);
42692 wake_up(&md_event_waiters);
42693 }
42694
42695 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42696 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42697 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42698 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42699 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42700 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42701
42702 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42703 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42704 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42705 else
42706 sb->resync_offset = cpu_to_le64(0);
42707
42708 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42709 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42710
42711 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42712 sb->size = cpu_to_le64(mddev->dev_sectors);
42713 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42714 static ssize_t
42715 errors_show(struct md_rdev *rdev, char *page)
42716 {
42717 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42718 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42719 }
42720
42721 static ssize_t
42722 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42723 char *e;
42724 unsigned long n = simple_strtoul(buf, &e, 10);
42725 if (*buf && (*e == 0 || *e == '\n')) {
42726 - atomic_set(&rdev->corrected_errors, n);
42727 + atomic_set_unchecked(&rdev->corrected_errors, n);
42728 return len;
42729 }
42730 return -EINVAL;
42731 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
42732 rdev->sb_loaded = 0;
42733 rdev->bb_page = NULL;
42734 atomic_set(&rdev->nr_pending, 0);
42735 - atomic_set(&rdev->read_errors, 0);
42736 - atomic_set(&rdev->corrected_errors, 0);
42737 + atomic_set_unchecked(&rdev->read_errors, 0);
42738 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42739
42740 INIT_LIST_HEAD(&rdev->same_set);
42741 init_waitqueue_head(&rdev->blocked_wait);
42742 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42743
42744 spin_unlock(&pers_lock);
42745 seq_printf(seq, "\n");
42746 - seq->poll_event = atomic_read(&md_event_count);
42747 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42748 return 0;
42749 }
42750 if (v == (void*)2) {
42751 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42752 return error;
42753
42754 seq = file->private_data;
42755 - seq->poll_event = atomic_read(&md_event_count);
42756 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42757 return error;
42758 }
42759
42760 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42761 /* always allow read */
42762 mask = POLLIN | POLLRDNORM;
42763
42764 - if (seq->poll_event != atomic_read(&md_event_count))
42765 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42766 mask |= POLLERR | POLLPRI;
42767 return mask;
42768 }
42769 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42770 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42771 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42772 (int)part_stat_read(&disk->part0, sectors[1]) -
42773 - atomic_read(&disk->sync_io);
42774 + atomic_read_unchecked(&disk->sync_io);
42775 /* sync IO will cause sync_io to increase before the disk_stats
42776 * as sync_io is counted when a request starts, and
42777 * disk_stats is counted when it completes.
42778 diff --git a/drivers/md/md.h b/drivers/md/md.h
42779 index 653f992b6..6af6c40 100644
42780 --- a/drivers/md/md.h
42781 +++ b/drivers/md/md.h
42782 @@ -94,13 +94,13 @@ struct md_rdev {
42783 * only maintained for arrays that
42784 * support hot removal
42785 */
42786 - atomic_t read_errors; /* number of consecutive read errors that
42787 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42788 * we have tried to ignore.
42789 */
42790 struct timespec last_read_error; /* monotonic time since our
42791 * last read error
42792 */
42793 - atomic_t corrected_errors; /* number of corrected read errors,
42794 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42795 * for reporting to userspace and storing
42796 * in superblock.
42797 */
42798 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42799
42800 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42801 {
42802 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42803 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42804 }
42805
42806 struct md_personality
42807 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42808 index 3e6d115..ffecdeb 100644
42809 --- a/drivers/md/persistent-data/dm-space-map.h
42810 +++ b/drivers/md/persistent-data/dm-space-map.h
42811 @@ -71,6 +71,7 @@ struct dm_space_map {
42812 dm_sm_threshold_fn fn,
42813 void *context);
42814 };
42815 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42816
42817 /*----------------------------------------------------------------*/
42818
42819 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42820 index 6f48244..7d29145 100644
42821 --- a/drivers/md/raid1.c
42822 +++ b/drivers/md/raid1.c
42823 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42824 if (r1_sync_page_io(rdev, sect, s,
42825 bio->bi_io_vec[idx].bv_page,
42826 READ) != 0)
42827 - atomic_add(s, &rdev->corrected_errors);
42828 + atomic_add_unchecked(s, &rdev->corrected_errors);
42829 }
42830 sectors -= s;
42831 sect += s;
42832 @@ -2049,7 +2049,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42833 test_bit(In_sync, &rdev->flags)) {
42834 if (r1_sync_page_io(rdev, sect, s,
42835 conf->tmppage, READ)) {
42836 - atomic_add(s, &rdev->corrected_errors);
42837 + atomic_add_unchecked(s, &rdev->corrected_errors);
42838 printk(KERN_INFO
42839 "md/raid1:%s: read error corrected "
42840 "(%d sectors at %llu on %s)\n",
42841 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42842 index 081bb33..3c4b287 100644
42843 --- a/drivers/md/raid10.c
42844 +++ b/drivers/md/raid10.c
42845 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
42846 /* The write handler will notice the lack of
42847 * R10BIO_Uptodate and record any errors etc
42848 */
42849 - atomic_add(r10_bio->sectors,
42850 + atomic_add_unchecked(r10_bio->sectors,
42851 &conf->mirrors[d].rdev->corrected_errors);
42852
42853 /* for reconstruct, we always reschedule after a read.
42854 @@ -2298,7 +2298,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42855 {
42856 struct timespec cur_time_mon;
42857 unsigned long hours_since_last;
42858 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42859 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42860
42861 ktime_get_ts(&cur_time_mon);
42862
42863 @@ -2320,9 +2320,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42864 * overflowing the shift of read_errors by hours_since_last.
42865 */
42866 if (hours_since_last >= 8 * sizeof(read_errors))
42867 - atomic_set(&rdev->read_errors, 0);
42868 + atomic_set_unchecked(&rdev->read_errors, 0);
42869 else
42870 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42871 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42872 }
42873
42874 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42875 @@ -2376,8 +2376,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42876 return;
42877
42878 check_decay_read_errors(mddev, rdev);
42879 - atomic_inc(&rdev->read_errors);
42880 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42881 + atomic_inc_unchecked(&rdev->read_errors);
42882 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42883 char b[BDEVNAME_SIZE];
42884 bdevname(rdev->bdev, b);
42885
42886 @@ -2385,7 +2385,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42887 "md/raid10:%s: %s: Raid device exceeded "
42888 "read_error threshold [cur %d:max %d]\n",
42889 mdname(mddev), b,
42890 - atomic_read(&rdev->read_errors), max_read_errors);
42891 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42892 printk(KERN_NOTICE
42893 "md/raid10:%s: %s: Failing raid device\n",
42894 mdname(mddev), b);
42895 @@ -2540,7 +2540,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42896 sect +
42897 choose_data_offset(r10_bio, rdev)),
42898 bdevname(rdev->bdev, b));
42899 - atomic_add(s, &rdev->corrected_errors);
42900 + atomic_add_unchecked(s, &rdev->corrected_errors);
42901 }
42902
42903 rdev_dec_pending(rdev, mddev);
42904 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42905 index a35b846..e295c6d 100644
42906 --- a/drivers/md/raid5.c
42907 +++ b/drivers/md/raid5.c
42908 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42909 mdname(conf->mddev), STRIPE_SECTORS,
42910 (unsigned long long)s,
42911 bdevname(rdev->bdev, b));
42912 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42913 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42914 clear_bit(R5_ReadError, &sh->dev[i].flags);
42915 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42916 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42917 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42918
42919 - if (atomic_read(&rdev->read_errors))
42920 - atomic_set(&rdev->read_errors, 0);
42921 + if (atomic_read_unchecked(&rdev->read_errors))
42922 + atomic_set_unchecked(&rdev->read_errors, 0);
42923 } else {
42924 const char *bdn = bdevname(rdev->bdev, b);
42925 int retry = 0;
42926 int set_bad = 0;
42927
42928 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42929 - atomic_inc(&rdev->read_errors);
42930 + atomic_inc_unchecked(&rdev->read_errors);
42931 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42932 printk_ratelimited(
42933 KERN_WARNING
42934 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42935 mdname(conf->mddev),
42936 (unsigned long long)s,
42937 bdn);
42938 - } else if (atomic_read(&rdev->read_errors)
42939 + } else if (atomic_read_unchecked(&rdev->read_errors)
42940 > conf->max_nr_stripes)
42941 printk(KERN_WARNING
42942 "md/raid:%s: Too many read errors, failing device %s.\n",
42943 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42944 index 401ef64..836e563 100644
42945 --- a/drivers/media/dvb-core/dvbdev.c
42946 +++ b/drivers/media/dvb-core/dvbdev.c
42947 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42948 const struct dvb_device *template, void *priv, int type)
42949 {
42950 struct dvb_device *dvbdev;
42951 - struct file_operations *dvbdevfops;
42952 + file_operations_no_const *dvbdevfops;
42953 struct device *clsdev;
42954 int minor;
42955 int id;
42956 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42957 index 9b6c3bb..baeb5c7 100644
42958 --- a/drivers/media/dvb-frontends/dib3000.h
42959 +++ b/drivers/media/dvb-frontends/dib3000.h
42960 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42961 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42962 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42963 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42964 -};
42965 +} __no_const;
42966
42967 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42968 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42969 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42970 index c7a9be1..683f6f8 100644
42971 --- a/drivers/media/pci/cx88/cx88-video.c
42972 +++ b/drivers/media/pci/cx88/cx88-video.c
42973 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42974
42975 /* ------------------------------------------------------------------ */
42976
42977 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42978 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42979 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42980 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42981 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42982 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42983
42984 module_param_array(video_nr, int, NULL, 0444);
42985 module_param_array(vbi_nr, int, NULL, 0444);
42986 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42987 index 07b8460..e6d7265 100644
42988 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42989 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42990 @@ -84,7 +84,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42991 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42992
42993 /* ivtv instance counter */
42994 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42995 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42996
42997 /* Parameter declarations */
42998 static int cardtype[IVTV_MAX_CARDS];
42999 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
43000 index d338b19..aae4f9e 100644
43001 --- a/drivers/media/platform/omap/omap_vout.c
43002 +++ b/drivers/media/platform/omap/omap_vout.c
43003 @@ -63,7 +63,6 @@ enum omap_vout_channels {
43004 OMAP_VIDEO2,
43005 };
43006
43007 -static struct videobuf_queue_ops video_vbq_ops;
43008 /* Variables configurable through module params*/
43009 static u32 video1_numbuffers = 3;
43010 static u32 video2_numbuffers = 3;
43011 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
43012 {
43013 struct videobuf_queue *q;
43014 struct omap_vout_device *vout = NULL;
43015 + static struct videobuf_queue_ops video_vbq_ops = {
43016 + .buf_setup = omap_vout_buffer_setup,
43017 + .buf_prepare = omap_vout_buffer_prepare,
43018 + .buf_release = omap_vout_buffer_release,
43019 + .buf_queue = omap_vout_buffer_queue,
43020 + };
43021
43022 vout = video_drvdata(file);
43023 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
43024 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
43025 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
43026
43027 q = &vout->vbq;
43028 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
43029 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
43030 - video_vbq_ops.buf_release = omap_vout_buffer_release;
43031 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
43032 spin_lock_init(&vout->vbq_lock);
43033
43034 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
43035 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
43036 index 04e6490..2df65bf 100644
43037 --- a/drivers/media/platform/s5p-tv/mixer.h
43038 +++ b/drivers/media/platform/s5p-tv/mixer.h
43039 @@ -156,7 +156,7 @@ struct mxr_layer {
43040 /** layer index (unique identifier) */
43041 int idx;
43042 /** callbacks for layer methods */
43043 - struct mxr_layer_ops ops;
43044 + struct mxr_layer_ops *ops;
43045 /** format array */
43046 const struct mxr_format **fmt_array;
43047 /** size of format array */
43048 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
43049 index b93a21f..2535195 100644
43050 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
43051 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
43052 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
43053 {
43054 struct mxr_layer *layer;
43055 int ret;
43056 - struct mxr_layer_ops ops = {
43057 + static struct mxr_layer_ops ops = {
43058 .release = mxr_graph_layer_release,
43059 .buffer_set = mxr_graph_buffer_set,
43060 .stream_set = mxr_graph_stream_set,
43061 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
43062 index b713403..53cb5ad 100644
43063 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
43064 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
43065 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
43066 layer->update_buf = next;
43067 }
43068
43069 - layer->ops.buffer_set(layer, layer->update_buf);
43070 + layer->ops->buffer_set(layer, layer->update_buf);
43071
43072 if (done && done != layer->shadow_buf)
43073 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
43074 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
43075 index ef0efdf..8c78eb6 100644
43076 --- a/drivers/media/platform/s5p-tv/mixer_video.c
43077 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
43078 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
43079 layer->geo.src.height = layer->geo.src.full_height;
43080
43081 mxr_geometry_dump(mdev, &layer->geo);
43082 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43083 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43084 mxr_geometry_dump(mdev, &layer->geo);
43085 }
43086
43087 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
43088 layer->geo.dst.full_width = mbus_fmt.width;
43089 layer->geo.dst.full_height = mbus_fmt.height;
43090 layer->geo.dst.field = mbus_fmt.field;
43091 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43092 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43093
43094 mxr_geometry_dump(mdev, &layer->geo);
43095 }
43096 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
43097 /* set source size to highest accepted value */
43098 geo->src.full_width = max(geo->dst.full_width, pix->width);
43099 geo->src.full_height = max(geo->dst.full_height, pix->height);
43100 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43101 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43102 mxr_geometry_dump(mdev, &layer->geo);
43103 /* set cropping to total visible screen */
43104 geo->src.width = pix->width;
43105 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
43106 geo->src.x_offset = 0;
43107 geo->src.y_offset = 0;
43108 /* assure consistency of geometry */
43109 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43110 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43111 mxr_geometry_dump(mdev, &layer->geo);
43112 /* set full size to lowest possible value */
43113 geo->src.full_width = 0;
43114 geo->src.full_height = 0;
43115 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43116 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43117 mxr_geometry_dump(mdev, &layer->geo);
43118
43119 /* returning results */
43120 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
43121 target->width = s->r.width;
43122 target->height = s->r.height;
43123
43124 - layer->ops.fix_geometry(layer, stage, s->flags);
43125 + layer->ops->fix_geometry(layer, stage, s->flags);
43126
43127 /* retrieve update selection rectangle */
43128 res.left = target->x_offset;
43129 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
43130 mxr_output_get(mdev);
43131
43132 mxr_layer_update_output(layer);
43133 - layer->ops.format_set(layer);
43134 + layer->ops->format_set(layer);
43135 /* enabling layer in hardware */
43136 spin_lock_irqsave(&layer->enq_slock, flags);
43137 layer->state = MXR_LAYER_STREAMING;
43138 spin_unlock_irqrestore(&layer->enq_slock, flags);
43139
43140 - layer->ops.stream_set(layer, MXR_ENABLE);
43141 + layer->ops->stream_set(layer, MXR_ENABLE);
43142 mxr_streamer_get(mdev);
43143
43144 return 0;
43145 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
43146 spin_unlock_irqrestore(&layer->enq_slock, flags);
43147
43148 /* disabling layer in hardware */
43149 - layer->ops.stream_set(layer, MXR_DISABLE);
43150 + layer->ops->stream_set(layer, MXR_DISABLE);
43151 /* remove one streamer */
43152 mxr_streamer_put(mdev);
43153 /* allow changes in output configuration */
43154 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
43155
43156 void mxr_layer_release(struct mxr_layer *layer)
43157 {
43158 - if (layer->ops.release)
43159 - layer->ops.release(layer);
43160 + if (layer->ops->release)
43161 + layer->ops->release(layer);
43162 }
43163
43164 void mxr_base_layer_release(struct mxr_layer *layer)
43165 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
43166
43167 layer->mdev = mdev;
43168 layer->idx = idx;
43169 - layer->ops = *ops;
43170 + layer->ops = ops;
43171
43172 spin_lock_init(&layer->enq_slock);
43173 INIT_LIST_HEAD(&layer->enq_list);
43174 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43175 index 3d13a63..da31bf1 100644
43176 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43177 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43178 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
43179 {
43180 struct mxr_layer *layer;
43181 int ret;
43182 - struct mxr_layer_ops ops = {
43183 + static struct mxr_layer_ops ops = {
43184 .release = mxr_vp_layer_release,
43185 .buffer_set = mxr_vp_buffer_set,
43186 .stream_set = mxr_vp_stream_set,
43187 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
43188 index 545c04c..a14bded 100644
43189 --- a/drivers/media/radio/radio-cadet.c
43190 +++ b/drivers/media/radio/radio-cadet.c
43191 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43192 unsigned char readbuf[RDS_BUFFER];
43193 int i = 0;
43194
43195 + if (count > RDS_BUFFER)
43196 + return -EFAULT;
43197 mutex_lock(&dev->lock);
43198 if (dev->rdsstat == 0)
43199 cadet_start_rds(dev);
43200 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43201 while (i < count && dev->rdsin != dev->rdsout)
43202 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
43203
43204 - if (i && copy_to_user(data, readbuf, i))
43205 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
43206 i = -EFAULT;
43207 unlock:
43208 mutex_unlock(&dev->lock);
43209 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
43210 index bd4d3a7..ffc0b9d 100644
43211 --- a/drivers/media/radio/radio-maxiradio.c
43212 +++ b/drivers/media/radio/radio-maxiradio.c
43213 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
43214 /* TEA5757 pin mappings */
43215 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
43216
43217 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
43218 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
43219
43220 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
43221 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
43222 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
43223 index 8fa18ab..caee70f 100644
43224 --- a/drivers/media/radio/radio-shark.c
43225 +++ b/drivers/media/radio/radio-shark.c
43226 @@ -79,7 +79,7 @@ struct shark_device {
43227 u32 last_val;
43228 };
43229
43230 -static atomic_t shark_instance = ATOMIC_INIT(0);
43231 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43232
43233 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43234 {
43235 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43236 index 9fb6697..f167415 100644
43237 --- a/drivers/media/radio/radio-shark2.c
43238 +++ b/drivers/media/radio/radio-shark2.c
43239 @@ -74,7 +74,7 @@ struct shark_device {
43240 u8 *transfer_buffer;
43241 };
43242
43243 -static atomic_t shark_instance = ATOMIC_INIT(0);
43244 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43245
43246 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43247 {
43248 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43249 index 9dc8baf..796d52f 100644
43250 --- a/drivers/media/radio/radio-si476x.c
43251 +++ b/drivers/media/radio/radio-si476x.c
43252 @@ -1456,7 +1456,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43253 struct si476x_radio *radio;
43254 struct v4l2_ctrl *ctrl;
43255
43256 - static atomic_t instance = ATOMIC_INIT(0);
43257 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43258
43259 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43260 if (!radio)
43261 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43262 index 1cf382a..c22998c 100644
43263 --- a/drivers/media/rc/rc-main.c
43264 +++ b/drivers/media/rc/rc-main.c
43265 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43266 int rc_register_device(struct rc_dev *dev)
43267 {
43268 static bool raw_init = false; /* raw decoders loaded? */
43269 - static atomic_t devno = ATOMIC_INIT(0);
43270 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43271 struct rc_map *rc_map;
43272 const char *path;
43273 int rc;
43274 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
43275 */
43276 mutex_lock(&dev->lock);
43277
43278 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43279 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43280 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43281 dev_set_drvdata(&dev->dev, dev);
43282 rc = device_add(&dev->dev);
43283 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43284 index 3940bb0..fb3952a 100644
43285 --- a/drivers/media/usb/dvb-usb/cxusb.c
43286 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43287 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43288
43289 struct dib0700_adapter_state {
43290 int (*set_param_save) (struct dvb_frontend *);
43291 -};
43292 +} __no_const;
43293
43294 static int dib7070_set_param_override(struct dvb_frontend *fe)
43295 {
43296 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43297 index 6e237b6..dc25556 100644
43298 --- a/drivers/media/usb/dvb-usb/dw2102.c
43299 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43300 @@ -118,7 +118,7 @@ struct su3000_state {
43301
43302 struct s6x0_state {
43303 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43304 -};
43305 +} __no_const;
43306
43307 /* debug */
43308 static int dvb_usb_dw2102_debug;
43309 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43310 index f129551..ecf6514 100644
43311 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43312 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43313 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43314 __u32 reserved;
43315 };
43316
43317 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43318 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43319 enum v4l2_memory memory)
43320 {
43321 void __user *up_pln;
43322 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43323 return 0;
43324 }
43325
43326 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43327 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43328 enum v4l2_memory memory)
43329 {
43330 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43331 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43332 put_user(kp->start_block, &up->start_block) ||
43333 put_user(kp->blocks, &up->blocks) ||
43334 put_user(tmp, &up->edid) ||
43335 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43336 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43337 return -EFAULT;
43338 return 0;
43339 }
43340 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43341 index 8ed5da2..47fee46 100644
43342 --- a/drivers/media/v4l2-core/v4l2-device.c
43343 +++ b/drivers/media/v4l2-core/v4l2-device.c
43344 @@ -74,9 +74,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43345 EXPORT_SYMBOL_GPL(v4l2_device_put);
43346
43347 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43348 - atomic_t *instance)
43349 + atomic_unchecked_t *instance)
43350 {
43351 - int num = atomic_inc_return(instance) - 1;
43352 + int num = atomic_inc_return_unchecked(instance) - 1;
43353 int len = strlen(basename);
43354
43355 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43356 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43357 index 7658586..1079260 100644
43358 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43359 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43360 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
43361 struct file *file, void *fh, void *p);
43362 } u;
43363 void (*debug)(const void *arg, bool write_only);
43364 -};
43365 +} __do_const;
43366 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43367
43368 /* This control needs a priority check */
43369 #define INFO_FL_PRIO (1 << 0)
43370 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
43371 struct video_device *vfd = video_devdata(file);
43372 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43373 bool write_only = false;
43374 - struct v4l2_ioctl_info default_info;
43375 + v4l2_ioctl_info_no_const default_info;
43376 const struct v4l2_ioctl_info *info;
43377 void *fh = file->private_data;
43378 struct v4l2_fh *vfh = NULL;
43379 @@ -2251,7 +2252,7 @@ done:
43380 }
43381
43382 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43383 - void * __user *user_ptr, void ***kernel_ptr)
43384 + void __user **user_ptr, void ***kernel_ptr)
43385 {
43386 int ret = 0;
43387
43388 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43389 ret = -EINVAL;
43390 break;
43391 }
43392 - *user_ptr = (void __user *)buf->m.planes;
43393 + *user_ptr = (void __force_user *)buf->m.planes;
43394 *kernel_ptr = (void *)&buf->m.planes;
43395 *array_size = sizeof(struct v4l2_plane) * buf->length;
43396 ret = 1;
43397 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43398 ret = -EINVAL;
43399 break;
43400 }
43401 - *user_ptr = (void __user *)ctrls->controls;
43402 + *user_ptr = (void __force_user *)ctrls->controls;
43403 *kernel_ptr = (void *)&ctrls->controls;
43404 *array_size = sizeof(struct v4l2_ext_control)
43405 * ctrls->count;
43406 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43407 index 767ff4d..c69d259 100644
43408 --- a/drivers/message/fusion/mptbase.c
43409 +++ b/drivers/message/fusion/mptbase.c
43410 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43411 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43412 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43413
43414 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43415 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43416 +#else
43417 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43418 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43419 +#endif
43420 +
43421 /*
43422 * Rounding UP to nearest 4-kB boundary here...
43423 */
43424 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43425 ioc->facts.GlobalCredits);
43426
43427 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43428 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43429 + NULL, NULL);
43430 +#else
43431 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43432 +#endif
43433 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43434 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43435 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43436 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43437 index dd239bd..689c4f7 100644
43438 --- a/drivers/message/fusion/mptsas.c
43439 +++ b/drivers/message/fusion/mptsas.c
43440 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43441 return 0;
43442 }
43443
43444 +static inline void
43445 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43446 +{
43447 + if (phy_info->port_details) {
43448 + phy_info->port_details->rphy = rphy;
43449 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43450 + ioc->name, rphy));
43451 + }
43452 +
43453 + if (rphy) {
43454 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43455 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43456 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43457 + ioc->name, rphy, rphy->dev.release));
43458 + }
43459 +}
43460 +
43461 /* no mutex */
43462 static void
43463 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43464 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43465 return NULL;
43466 }
43467
43468 -static inline void
43469 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43470 -{
43471 - if (phy_info->port_details) {
43472 - phy_info->port_details->rphy = rphy;
43473 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43474 - ioc->name, rphy));
43475 - }
43476 -
43477 - if (rphy) {
43478 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43479 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43480 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43481 - ioc->name, rphy, rphy->dev.release));
43482 - }
43483 -}
43484 -
43485 static inline struct sas_port *
43486 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43487 {
43488 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43489 index 727819c..ad74694 100644
43490 --- a/drivers/message/fusion/mptscsih.c
43491 +++ b/drivers/message/fusion/mptscsih.c
43492 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43493
43494 h = shost_priv(SChost);
43495
43496 - if (h) {
43497 - if (h->info_kbuf == NULL)
43498 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43499 - return h->info_kbuf;
43500 - h->info_kbuf[0] = '\0';
43501 + if (!h)
43502 + return NULL;
43503
43504 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43505 - h->info_kbuf[size-1] = '\0';
43506 - }
43507 + if (h->info_kbuf == NULL)
43508 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43509 + return h->info_kbuf;
43510 + h->info_kbuf[0] = '\0';
43511 +
43512 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43513 + h->info_kbuf[size-1] = '\0';
43514
43515 return h->info_kbuf;
43516 }
43517 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43518 index b7d87cd..9890039 100644
43519 --- a/drivers/message/i2o/i2o_proc.c
43520 +++ b/drivers/message/i2o/i2o_proc.c
43521 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43522 "Array Controller Device"
43523 };
43524
43525 -static char *chtostr(char *tmp, u8 *chars, int n)
43526 -{
43527 - tmp[0] = 0;
43528 - return strncat(tmp, (char *)chars, n);
43529 -}
43530 -
43531 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43532 char *group)
43533 {
43534 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43535 } *result;
43536
43537 i2o_exec_execute_ddm_table ddm_table;
43538 - char tmp[28 + 1];
43539
43540 result = kmalloc(sizeof(*result), GFP_KERNEL);
43541 if (!result)
43542 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43543
43544 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43545 seq_printf(seq, "%-#8x", ddm_table.module_id);
43546 - seq_printf(seq, "%-29s",
43547 - chtostr(tmp, ddm_table.module_name_version, 28));
43548 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43549 seq_printf(seq, "%9d ", ddm_table.data_size);
43550 seq_printf(seq, "%8d", ddm_table.code_size);
43551
43552 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43553
43554 i2o_driver_result_table *result;
43555 i2o_driver_store_table *dst;
43556 - char tmp[28 + 1];
43557
43558 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43559 if (result == NULL)
43560 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43561
43562 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43563 seq_printf(seq, "%-#8x", dst->module_id);
43564 - seq_printf(seq, "%-29s",
43565 - chtostr(tmp, dst->module_name_version, 28));
43566 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43567 + seq_printf(seq, "%-.28s", dst->module_name_version);
43568 + seq_printf(seq, "%-.8s", dst->date);
43569 seq_printf(seq, "%8d ", dst->module_size);
43570 seq_printf(seq, "%8d ", dst->mpb_size);
43571 seq_printf(seq, "0x%04x", dst->module_flags);
43572 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43573 // == (allow) 512d bytes (max)
43574 static u16 *work16 = (u16 *) work32;
43575 int token;
43576 - char tmp[16 + 1];
43577
43578 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43579
43580 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43581 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43582 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43583 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43584 - seq_printf(seq, "Vendor info : %s\n",
43585 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43586 - seq_printf(seq, "Product info : %s\n",
43587 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43588 - seq_printf(seq, "Description : %s\n",
43589 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43590 - seq_printf(seq, "Product rev. : %s\n",
43591 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43592 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43593 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43594 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43595 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43596
43597 seq_printf(seq, "Serial number : ");
43598 print_serial_number(seq, (u8 *) (work32 + 16),
43599 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43600 u8 pad[256]; // allow up to 256 byte (max) serial number
43601 } result;
43602
43603 - char tmp[24 + 1];
43604 -
43605 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43606
43607 if (token < 0) {
43608 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43609 }
43610
43611 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43612 - seq_printf(seq, "Module name : %s\n",
43613 - chtostr(tmp, result.module_name, 24));
43614 - seq_printf(seq, "Module revision : %s\n",
43615 - chtostr(tmp, result.module_rev, 8));
43616 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43617 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43618
43619 seq_printf(seq, "Serial number : ");
43620 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43621 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43622 u8 instance_number[4];
43623 } result;
43624
43625 - char tmp[64 + 1];
43626 -
43627 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43628
43629 if (token < 0) {
43630 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43631 return 0;
43632 }
43633
43634 - seq_printf(seq, "Device name : %s\n",
43635 - chtostr(tmp, result.device_name, 64));
43636 - seq_printf(seq, "Service name : %s\n",
43637 - chtostr(tmp, result.service_name, 64));
43638 - seq_printf(seq, "Physical name : %s\n",
43639 - chtostr(tmp, result.physical_location, 64));
43640 - seq_printf(seq, "Instance number : %s\n",
43641 - chtostr(tmp, result.instance_number, 4));
43642 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43643 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43644 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43645 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43646
43647 return 0;
43648 }
43649 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43650 index a8c08f3..155fe3d 100644
43651 --- a/drivers/message/i2o/iop.c
43652 +++ b/drivers/message/i2o/iop.c
43653 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43654
43655 spin_lock_irqsave(&c->context_list_lock, flags);
43656
43657 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43658 - atomic_inc(&c->context_list_counter);
43659 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43660 + atomic_inc_unchecked(&c->context_list_counter);
43661
43662 - entry->context = atomic_read(&c->context_list_counter);
43663 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43664
43665 list_add(&entry->list, &c->context_list);
43666
43667 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43668
43669 #if BITS_PER_LONG == 64
43670 spin_lock_init(&c->context_list_lock);
43671 - atomic_set(&c->context_list_counter, 0);
43672 + atomic_set_unchecked(&c->context_list_counter, 0);
43673 INIT_LIST_HEAD(&c->context_list);
43674 #endif
43675
43676 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43677 index 45ece11..8efa218 100644
43678 --- a/drivers/mfd/janz-cmodio.c
43679 +++ b/drivers/mfd/janz-cmodio.c
43680 @@ -13,6 +13,7 @@
43681
43682 #include <linux/kernel.h>
43683 #include <linux/module.h>
43684 +#include <linux/slab.h>
43685 #include <linux/init.h>
43686 #include <linux/pci.h>
43687 #include <linux/interrupt.h>
43688 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43689 index a5f9888..1c0ed56 100644
43690 --- a/drivers/mfd/twl4030-irq.c
43691 +++ b/drivers/mfd/twl4030-irq.c
43692 @@ -35,6 +35,7 @@
43693 #include <linux/of.h>
43694 #include <linux/irqdomain.h>
43695 #include <linux/i2c/twl.h>
43696 +#include <asm/pgtable.h>
43697
43698 #include "twl-core.h"
43699
43700 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43701 * Install an irq handler for each of the SIH modules;
43702 * clone dummy irq_chip since PIH can't *do* anything
43703 */
43704 - twl4030_irq_chip = dummy_irq_chip;
43705 - twl4030_irq_chip.name = "twl4030";
43706 + pax_open_kernel();
43707 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43708 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43709
43710 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43711 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43712 + pax_close_kernel();
43713
43714 for (i = irq_base; i < irq_end; i++) {
43715 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43716 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43717 index 277a8db..0e0b754 100644
43718 --- a/drivers/mfd/twl6030-irq.c
43719 +++ b/drivers/mfd/twl6030-irq.c
43720 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43721 * install an irq handler for each of the modules;
43722 * clone dummy irq_chip since PIH can't *do* anything
43723 */
43724 - twl6030_irq_chip = dummy_irq_chip;
43725 - twl6030_irq_chip.name = "twl6030";
43726 - twl6030_irq_chip.irq_set_type = NULL;
43727 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43728 + pax_open_kernel();
43729 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43730 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43731 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43732 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43733 + pax_close_kernel();
43734
43735 for (i = irq_base; i < irq_end; i++) {
43736 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43737 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43738 index f32550a..e3e52a2 100644
43739 --- a/drivers/misc/c2port/core.c
43740 +++ b/drivers/misc/c2port/core.c
43741 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43742 mutex_init(&c2dev->mutex);
43743
43744 /* Create binary file */
43745 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43746 + pax_open_kernel();
43747 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43748 + pax_close_kernel();
43749 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43750 if (unlikely(ret))
43751 goto error_device_create_bin_file;
43752 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43753 index 36f5d52..32311c3 100644
43754 --- a/drivers/misc/kgdbts.c
43755 +++ b/drivers/misc/kgdbts.c
43756 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43757 char before[BREAK_INSTR_SIZE];
43758 char after[BREAK_INSTR_SIZE];
43759
43760 - probe_kernel_read(before, (char *)kgdbts_break_test,
43761 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43762 BREAK_INSTR_SIZE);
43763 init_simple_test();
43764 ts.tst = plant_and_detach_test;
43765 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43766 /* Activate test with initial breakpoint */
43767 if (!is_early)
43768 kgdb_breakpoint();
43769 - probe_kernel_read(after, (char *)kgdbts_break_test,
43770 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43771 BREAK_INSTR_SIZE);
43772 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43773 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43774 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43775 index 4cd4a3d..b48cbc7 100644
43776 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43777 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43778 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43779 * the lid is closed. This leads to interrupts as soon as a little move
43780 * is done.
43781 */
43782 - atomic_inc(&lis3->count);
43783 + atomic_inc_unchecked(&lis3->count);
43784
43785 wake_up_interruptible(&lis3->misc_wait);
43786 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43787 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43788 if (lis3->pm_dev)
43789 pm_runtime_get_sync(lis3->pm_dev);
43790
43791 - atomic_set(&lis3->count, 0);
43792 + atomic_set_unchecked(&lis3->count, 0);
43793 return 0;
43794 }
43795
43796 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43797 add_wait_queue(&lis3->misc_wait, &wait);
43798 while (true) {
43799 set_current_state(TASK_INTERRUPTIBLE);
43800 - data = atomic_xchg(&lis3->count, 0);
43801 + data = atomic_xchg_unchecked(&lis3->count, 0);
43802 if (data)
43803 break;
43804
43805 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43806 struct lis3lv02d, miscdev);
43807
43808 poll_wait(file, &lis3->misc_wait, wait);
43809 - if (atomic_read(&lis3->count))
43810 + if (atomic_read_unchecked(&lis3->count))
43811 return POLLIN | POLLRDNORM;
43812 return 0;
43813 }
43814 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43815 index c439c82..1f20f57 100644
43816 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43817 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43818 @@ -297,7 +297,7 @@ struct lis3lv02d {
43819 struct input_polled_dev *idev; /* input device */
43820 struct platform_device *pdev; /* platform device */
43821 struct regulator_bulk_data regulators[2];
43822 - atomic_t count; /* interrupt count after last read */
43823 + atomic_unchecked_t count; /* interrupt count after last read */
43824 union axis_conversion ac; /* hw -> logical axis */
43825 int mapped_btns[3];
43826
43827 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43828 index 2f30bad..c4c13d0 100644
43829 --- a/drivers/misc/sgi-gru/gruhandles.c
43830 +++ b/drivers/misc/sgi-gru/gruhandles.c
43831 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43832 unsigned long nsec;
43833
43834 nsec = CLKS2NSEC(clks);
43835 - atomic_long_inc(&mcs_op_statistics[op].count);
43836 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43837 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43838 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43839 if (mcs_op_statistics[op].max < nsec)
43840 mcs_op_statistics[op].max = nsec;
43841 }
43842 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43843 index 797d796..ae8f01e 100644
43844 --- a/drivers/misc/sgi-gru/gruprocfs.c
43845 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43846 @@ -32,9 +32,9 @@
43847
43848 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43849
43850 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43851 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43852 {
43853 - unsigned long val = atomic_long_read(v);
43854 + unsigned long val = atomic_long_read_unchecked(v);
43855
43856 seq_printf(s, "%16lu %s\n", val, id);
43857 }
43858 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43859
43860 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43861 for (op = 0; op < mcsop_last; op++) {
43862 - count = atomic_long_read(&mcs_op_statistics[op].count);
43863 - total = atomic_long_read(&mcs_op_statistics[op].total);
43864 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43865 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43866 max = mcs_op_statistics[op].max;
43867 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43868 count ? total / count : 0, max);
43869 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43870 index 5c3ce24..4915ccb 100644
43871 --- a/drivers/misc/sgi-gru/grutables.h
43872 +++ b/drivers/misc/sgi-gru/grutables.h
43873 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43874 * GRU statistics.
43875 */
43876 struct gru_stats_s {
43877 - atomic_long_t vdata_alloc;
43878 - atomic_long_t vdata_free;
43879 - atomic_long_t gts_alloc;
43880 - atomic_long_t gts_free;
43881 - atomic_long_t gms_alloc;
43882 - atomic_long_t gms_free;
43883 - atomic_long_t gts_double_allocate;
43884 - atomic_long_t assign_context;
43885 - atomic_long_t assign_context_failed;
43886 - atomic_long_t free_context;
43887 - atomic_long_t load_user_context;
43888 - atomic_long_t load_kernel_context;
43889 - atomic_long_t lock_kernel_context;
43890 - atomic_long_t unlock_kernel_context;
43891 - atomic_long_t steal_user_context;
43892 - atomic_long_t steal_kernel_context;
43893 - atomic_long_t steal_context_failed;
43894 - atomic_long_t nopfn;
43895 - atomic_long_t asid_new;
43896 - atomic_long_t asid_next;
43897 - atomic_long_t asid_wrap;
43898 - atomic_long_t asid_reuse;
43899 - atomic_long_t intr;
43900 - atomic_long_t intr_cbr;
43901 - atomic_long_t intr_tfh;
43902 - atomic_long_t intr_spurious;
43903 - atomic_long_t intr_mm_lock_failed;
43904 - atomic_long_t call_os;
43905 - atomic_long_t call_os_wait_queue;
43906 - atomic_long_t user_flush_tlb;
43907 - atomic_long_t user_unload_context;
43908 - atomic_long_t user_exception;
43909 - atomic_long_t set_context_option;
43910 - atomic_long_t check_context_retarget_intr;
43911 - atomic_long_t check_context_unload;
43912 - atomic_long_t tlb_dropin;
43913 - atomic_long_t tlb_preload_page;
43914 - atomic_long_t tlb_dropin_fail_no_asid;
43915 - atomic_long_t tlb_dropin_fail_upm;
43916 - atomic_long_t tlb_dropin_fail_invalid;
43917 - atomic_long_t tlb_dropin_fail_range_active;
43918 - atomic_long_t tlb_dropin_fail_idle;
43919 - atomic_long_t tlb_dropin_fail_fmm;
43920 - atomic_long_t tlb_dropin_fail_no_exception;
43921 - atomic_long_t tfh_stale_on_fault;
43922 - atomic_long_t mmu_invalidate_range;
43923 - atomic_long_t mmu_invalidate_page;
43924 - atomic_long_t flush_tlb;
43925 - atomic_long_t flush_tlb_gru;
43926 - atomic_long_t flush_tlb_gru_tgh;
43927 - atomic_long_t flush_tlb_gru_zero_asid;
43928 + atomic_long_unchecked_t vdata_alloc;
43929 + atomic_long_unchecked_t vdata_free;
43930 + atomic_long_unchecked_t gts_alloc;
43931 + atomic_long_unchecked_t gts_free;
43932 + atomic_long_unchecked_t gms_alloc;
43933 + atomic_long_unchecked_t gms_free;
43934 + atomic_long_unchecked_t gts_double_allocate;
43935 + atomic_long_unchecked_t assign_context;
43936 + atomic_long_unchecked_t assign_context_failed;
43937 + atomic_long_unchecked_t free_context;
43938 + atomic_long_unchecked_t load_user_context;
43939 + atomic_long_unchecked_t load_kernel_context;
43940 + atomic_long_unchecked_t lock_kernel_context;
43941 + atomic_long_unchecked_t unlock_kernel_context;
43942 + atomic_long_unchecked_t steal_user_context;
43943 + atomic_long_unchecked_t steal_kernel_context;
43944 + atomic_long_unchecked_t steal_context_failed;
43945 + atomic_long_unchecked_t nopfn;
43946 + atomic_long_unchecked_t asid_new;
43947 + atomic_long_unchecked_t asid_next;
43948 + atomic_long_unchecked_t asid_wrap;
43949 + atomic_long_unchecked_t asid_reuse;
43950 + atomic_long_unchecked_t intr;
43951 + atomic_long_unchecked_t intr_cbr;
43952 + atomic_long_unchecked_t intr_tfh;
43953 + atomic_long_unchecked_t intr_spurious;
43954 + atomic_long_unchecked_t intr_mm_lock_failed;
43955 + atomic_long_unchecked_t call_os;
43956 + atomic_long_unchecked_t call_os_wait_queue;
43957 + atomic_long_unchecked_t user_flush_tlb;
43958 + atomic_long_unchecked_t user_unload_context;
43959 + atomic_long_unchecked_t user_exception;
43960 + atomic_long_unchecked_t set_context_option;
43961 + atomic_long_unchecked_t check_context_retarget_intr;
43962 + atomic_long_unchecked_t check_context_unload;
43963 + atomic_long_unchecked_t tlb_dropin;
43964 + atomic_long_unchecked_t tlb_preload_page;
43965 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43966 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43967 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43968 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43969 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43970 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43971 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43972 + atomic_long_unchecked_t tfh_stale_on_fault;
43973 + atomic_long_unchecked_t mmu_invalidate_range;
43974 + atomic_long_unchecked_t mmu_invalidate_page;
43975 + atomic_long_unchecked_t flush_tlb;
43976 + atomic_long_unchecked_t flush_tlb_gru;
43977 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43978 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43979
43980 - atomic_long_t copy_gpa;
43981 - atomic_long_t read_gpa;
43982 + atomic_long_unchecked_t copy_gpa;
43983 + atomic_long_unchecked_t read_gpa;
43984
43985 - atomic_long_t mesq_receive;
43986 - atomic_long_t mesq_receive_none;
43987 - atomic_long_t mesq_send;
43988 - atomic_long_t mesq_send_failed;
43989 - atomic_long_t mesq_noop;
43990 - atomic_long_t mesq_send_unexpected_error;
43991 - atomic_long_t mesq_send_lb_overflow;
43992 - atomic_long_t mesq_send_qlimit_reached;
43993 - atomic_long_t mesq_send_amo_nacked;
43994 - atomic_long_t mesq_send_put_nacked;
43995 - atomic_long_t mesq_page_overflow;
43996 - atomic_long_t mesq_qf_locked;
43997 - atomic_long_t mesq_qf_noop_not_full;
43998 - atomic_long_t mesq_qf_switch_head_failed;
43999 - atomic_long_t mesq_qf_unexpected_error;
44000 - atomic_long_t mesq_noop_unexpected_error;
44001 - atomic_long_t mesq_noop_lb_overflow;
44002 - atomic_long_t mesq_noop_qlimit_reached;
44003 - atomic_long_t mesq_noop_amo_nacked;
44004 - atomic_long_t mesq_noop_put_nacked;
44005 - atomic_long_t mesq_noop_page_overflow;
44006 + atomic_long_unchecked_t mesq_receive;
44007 + atomic_long_unchecked_t mesq_receive_none;
44008 + atomic_long_unchecked_t mesq_send;
44009 + atomic_long_unchecked_t mesq_send_failed;
44010 + atomic_long_unchecked_t mesq_noop;
44011 + atomic_long_unchecked_t mesq_send_unexpected_error;
44012 + atomic_long_unchecked_t mesq_send_lb_overflow;
44013 + atomic_long_unchecked_t mesq_send_qlimit_reached;
44014 + atomic_long_unchecked_t mesq_send_amo_nacked;
44015 + atomic_long_unchecked_t mesq_send_put_nacked;
44016 + atomic_long_unchecked_t mesq_page_overflow;
44017 + atomic_long_unchecked_t mesq_qf_locked;
44018 + atomic_long_unchecked_t mesq_qf_noop_not_full;
44019 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
44020 + atomic_long_unchecked_t mesq_qf_unexpected_error;
44021 + atomic_long_unchecked_t mesq_noop_unexpected_error;
44022 + atomic_long_unchecked_t mesq_noop_lb_overflow;
44023 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
44024 + atomic_long_unchecked_t mesq_noop_amo_nacked;
44025 + atomic_long_unchecked_t mesq_noop_put_nacked;
44026 + atomic_long_unchecked_t mesq_noop_page_overflow;
44027
44028 };
44029
44030 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
44031 tghop_invalidate, mcsop_last};
44032
44033 struct mcs_op_statistic {
44034 - atomic_long_t count;
44035 - atomic_long_t total;
44036 + atomic_long_unchecked_t count;
44037 + atomic_long_unchecked_t total;
44038 unsigned long max;
44039 };
44040
44041 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
44042
44043 #define STAT(id) do { \
44044 if (gru_options & OPT_STATS) \
44045 - atomic_long_inc(&gru_stats.id); \
44046 + atomic_long_inc_unchecked(&gru_stats.id); \
44047 } while (0)
44048
44049 #ifdef CONFIG_SGI_GRU_DEBUG
44050 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
44051 index c862cd4..0d176fe 100644
44052 --- a/drivers/misc/sgi-xp/xp.h
44053 +++ b/drivers/misc/sgi-xp/xp.h
44054 @@ -288,7 +288,7 @@ struct xpc_interface {
44055 xpc_notify_func, void *);
44056 void (*received) (short, int, void *);
44057 enum xp_retval (*partid_to_nasids) (short, void *);
44058 -};
44059 +} __no_const;
44060
44061 extern struct xpc_interface xpc_interface;
44062
44063 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
44064 index b94d5f7..7f494c5 100644
44065 --- a/drivers/misc/sgi-xp/xpc.h
44066 +++ b/drivers/misc/sgi-xp/xpc.h
44067 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
44068 void (*received_payload) (struct xpc_channel *, void *);
44069 void (*notify_senders_of_disconnect) (struct xpc_channel *);
44070 };
44071 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
44072
44073 /* struct xpc_partition act_state values (for XPC HB) */
44074
44075 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
44076 /* found in xpc_main.c */
44077 extern struct device *xpc_part;
44078 extern struct device *xpc_chan;
44079 -extern struct xpc_arch_operations xpc_arch_ops;
44080 +extern xpc_arch_operations_no_const xpc_arch_ops;
44081 extern int xpc_disengage_timelimit;
44082 extern int xpc_disengage_timedout;
44083 extern int xpc_activate_IRQ_rcvd;
44084 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
44085 index d971817..33bdca5 100644
44086 --- a/drivers/misc/sgi-xp/xpc_main.c
44087 +++ b/drivers/misc/sgi-xp/xpc_main.c
44088 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
44089 .notifier_call = xpc_system_die,
44090 };
44091
44092 -struct xpc_arch_operations xpc_arch_ops;
44093 +xpc_arch_operations_no_const xpc_arch_ops;
44094
44095 /*
44096 * Timer function to enforce the timelimit on the partition disengage.
44097 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
44098
44099 if (((die_args->trapnr == X86_TRAP_MF) ||
44100 (die_args->trapnr == X86_TRAP_XF)) &&
44101 - !user_mode_vm(die_args->regs))
44102 + !user_mode(die_args->regs))
44103 xpc_die_deactivate();
44104
44105 break;
44106 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
44107 index 49f04bc..65660c2 100644
44108 --- a/drivers/mmc/core/mmc_ops.c
44109 +++ b/drivers/mmc/core/mmc_ops.c
44110 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
44111 void *data_buf;
44112 int is_on_stack;
44113
44114 - is_on_stack = object_is_on_stack(buf);
44115 + is_on_stack = object_starts_on_stack(buf);
44116 if (is_on_stack) {
44117 /*
44118 * dma onto stack is unsafe/nonportable, but callers to this
44119 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
44120 index 0b74189..818358f 100644
44121 --- a/drivers/mmc/host/dw_mmc.h
44122 +++ b/drivers/mmc/host/dw_mmc.h
44123 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
44124 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
44125 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
44126 int (*parse_dt)(struct dw_mci *host);
44127 -};
44128 +} __do_const;
44129 #endif /* _DW_MMC_H_ */
44130 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
44131 index c6f6246..60760a8 100644
44132 --- a/drivers/mmc/host/sdhci-s3c.c
44133 +++ b/drivers/mmc/host/sdhci-s3c.c
44134 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
44135 * we can use overriding functions instead of default.
44136 */
44137 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
44138 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44139 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44140 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44141 + pax_open_kernel();
44142 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44143 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44144 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44145 + pax_close_kernel();
44146 }
44147
44148 /* It supports additional host capabilities if needed */
44149 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
44150 index 0c8bb6b..6f35deb 100644
44151 --- a/drivers/mtd/nand/denali.c
44152 +++ b/drivers/mtd/nand/denali.c
44153 @@ -24,6 +24,7 @@
44154 #include <linux/slab.h>
44155 #include <linux/mtd/mtd.h>
44156 #include <linux/module.h>
44157 +#include <linux/slab.h>
44158
44159 #include "denali.h"
44160
44161 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
44162 index 51b9d6a..52af9a7 100644
44163 --- a/drivers/mtd/nftlmount.c
44164 +++ b/drivers/mtd/nftlmount.c
44165 @@ -24,6 +24,7 @@
44166 #include <asm/errno.h>
44167 #include <linux/delay.h>
44168 #include <linux/slab.h>
44169 +#include <linux/sched.h>
44170 #include <linux/mtd/mtd.h>
44171 #include <linux/mtd/nand.h>
44172 #include <linux/mtd/nftl.h>
44173 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44174 index f9d5615..99dd95f 100644
44175 --- a/drivers/mtd/sm_ftl.c
44176 +++ b/drivers/mtd/sm_ftl.c
44177 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44178 #define SM_CIS_VENDOR_OFFSET 0x59
44179 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44180 {
44181 - struct attribute_group *attr_group;
44182 + attribute_group_no_const *attr_group;
44183 struct attribute **attributes;
44184 struct sm_sysfs_attribute *vendor_attribute;
44185
44186 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44187 index f975696..4597e21 100644
44188 --- a/drivers/net/bonding/bond_main.c
44189 +++ b/drivers/net/bonding/bond_main.c
44190 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
44191 return tx_queues;
44192 }
44193
44194 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44195 +static struct rtnl_link_ops bond_link_ops = {
44196 .kind = "bond",
44197 .priv_size = sizeof(struct bonding),
44198 .setup = bond_setup,
44199 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
44200
44201 bond_destroy_debugfs();
44202
44203 - rtnl_link_unregister(&bond_link_ops);
44204 unregister_pernet_subsys(&bond_net_ops);
44205 + rtnl_link_unregister(&bond_link_ops);
44206
44207 #ifdef CONFIG_NET_POLL_CONTROLLER
44208 /*
44209 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44210 index e1d2643..7f4133b 100644
44211 --- a/drivers/net/ethernet/8390/ax88796.c
44212 +++ b/drivers/net/ethernet/8390/ax88796.c
44213 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44214 if (ax->plat->reg_offsets)
44215 ei_local->reg_offset = ax->plat->reg_offsets;
44216 else {
44217 + resource_size_t _mem_size = mem_size;
44218 + do_div(_mem_size, 0x18);
44219 ei_local->reg_offset = ax->reg_offsets;
44220 for (ret = 0; ret < 0x18; ret++)
44221 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44222 + ax->reg_offsets[ret] = _mem_size * ret;
44223 }
44224
44225 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44226 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44227 index 151675d..0139a9d 100644
44228 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44229 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44230 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44231 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44232 {
44233 /* RX_MODE controlling object */
44234 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44235 + bnx2x_init_rx_mode_obj(bp);
44236
44237 /* multicast configuration controlling object */
44238 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44239 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
44240 index ce1a916..10b52b0 100644
44241 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
44242 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
44243 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
44244 struct bnx2x *bp = netdev_priv(dev);
44245
44246 /* Use the ethtool_dump "flag" field as the dump preset index */
44247 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
44248 + return -EINVAL;
44249 +
44250 bp->dump_preset_idx = val->flag;
44251 return 0;
44252 }
44253 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
44254 struct bnx2x *bp = netdev_priv(dev);
44255 struct dump_header dump_hdr = {0};
44256
44257 - memset(p, 0, dump->len);
44258 -
44259 /* Disable parity attentions as long as following dump may
44260 * cause false alarms by reading never written registers. We
44261 * will re-enable parity attentions right after the dump.
44262 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
44263 index b4c9dea..2a9927f 100644
44264 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
44265 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
44266 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
44267 bp->min_msix_vec_cnt = 2;
44268 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
44269
44270 + bp->dump_preset_idx = 1;
44271 +
44272 return rc;
44273 }
44274
44275 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44276 index 32a9609..0b1c53a 100644
44277 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44278 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44279 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44280 return rc;
44281 }
44282
44283 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44284 - struct bnx2x_rx_mode_obj *o)
44285 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44286 {
44287 if (CHIP_IS_E1x(bp)) {
44288 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44289 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44290 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44291 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44292 } else {
44293 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44294 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44295 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44296 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44297 }
44298 }
44299
44300 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44301 index 43c00bc..dd1d03d 100644
44302 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44303 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44304 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44305
44306 /********************* RX MODE ****************/
44307
44308 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44309 - struct bnx2x_rx_mode_obj *o);
44310 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44311
44312 /**
44313 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44314 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44315 index ff6e30e..87e8452 100644
44316 --- a/drivers/net/ethernet/broadcom/tg3.h
44317 +++ b/drivers/net/ethernet/broadcom/tg3.h
44318 @@ -147,6 +147,7 @@
44319 #define CHIPREV_ID_5750_A0 0x4000
44320 #define CHIPREV_ID_5750_A1 0x4001
44321 #define CHIPREV_ID_5750_A3 0x4003
44322 +#define CHIPREV_ID_5750_C1 0x4201
44323 #define CHIPREV_ID_5750_C2 0x4202
44324 #define CHIPREV_ID_5752_A0_HW 0x5000
44325 #define CHIPREV_ID_5752_A0 0x6000
44326 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
44327 index 71497e8..b650951 100644
44328 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
44329 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
44330 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
44331 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
44332 t3_read_reg(adapter, A_PCIE_PEX_ERR));
44333
44334 + rtnl_lock();
44335 t3_resume_ports(adapter);
44336 + rtnl_unlock();
44337 }
44338
44339 static const struct pci_error_handlers t3_err_handler = {
44340 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44341 index 8cffcdf..aadf043 100644
44342 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44343 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44344 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44345 */
44346 struct l2t_skb_cb {
44347 arp_failure_handler_func arp_failure_handler;
44348 -};
44349 +} __no_const;
44350
44351 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44352
44353 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44354 index 4c83003..2a2a5b9 100644
44355 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44356 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44357 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44358 for (i=0; i<ETH_ALEN; i++) {
44359 tmp.addr[i] = dev->dev_addr[i];
44360 }
44361 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44362 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44363 break;
44364
44365 case DE4X5_SET_HWADDR: /* Set the hardware address */
44366 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44367 spin_lock_irqsave(&lp->lock, flags);
44368 memcpy(&statbuf, &lp->pktStats, ioc->len);
44369 spin_unlock_irqrestore(&lp->lock, flags);
44370 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44371 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44372 return -EFAULT;
44373 break;
44374 }
44375 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44376 index 6e43426..1bd8365 100644
44377 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44378 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44379 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44380
44381 if (wrapped)
44382 newacc += 65536;
44383 - ACCESS_ONCE(*acc) = newacc;
44384 + ACCESS_ONCE_RW(*acc) = newacc;
44385 }
44386
44387 void populate_erx_stats(struct be_adapter *adapter,
44388 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44389 index 21b85fb..b49e5fc 100644
44390 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44391 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44392 @@ -31,6 +31,8 @@
44393 #include <linux/netdevice.h>
44394 #include <linux/phy.h>
44395 #include <linux/platform_device.h>
44396 +#include <linux/interrupt.h>
44397 +#include <linux/irqreturn.h>
44398 #include <net/ip.h>
44399
44400 #include "ftgmac100.h"
44401 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44402 index a6eda8d..935d273 100644
44403 --- a/drivers/net/ethernet/faraday/ftmac100.c
44404 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44405 @@ -31,6 +31,8 @@
44406 #include <linux/module.h>
44407 #include <linux/netdevice.h>
44408 #include <linux/platform_device.h>
44409 +#include <linux/interrupt.h>
44410 +#include <linux/irqreturn.h>
44411
44412 #include "ftmac100.h"
44413
44414 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44415 index 331987d..3be1135 100644
44416 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44417 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44418 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44419 }
44420
44421 /* update the base incval used to calculate frequency adjustment */
44422 - ACCESS_ONCE(adapter->base_incval) = incval;
44423 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44424 smp_mb();
44425
44426 /* need lock to prevent incorrect read while modifying cyclecounter */
44427 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44428 index fbe5363..266b4e3 100644
44429 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44430 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44431 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44432 struct __vxge_hw_fifo *fifo;
44433 struct vxge_hw_fifo_config *config;
44434 u32 txdl_size, txdl_per_memblock;
44435 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44436 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44437 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44438 + };
44439 +
44440 struct __vxge_hw_virtualpath *vpath;
44441
44442 if ((vp == NULL) || (attr == NULL)) {
44443 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44444 goto exit;
44445 }
44446
44447 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44448 -
44449 fifo->mempool =
44450 __vxge_hw_mempool_create(vpath->hldev,
44451 fifo->config->memblock_size,
44452 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44453 index 5e7fb1d..f8d1810 100644
44454 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44455 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44456 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44457 op_mode = QLC_83XX_DEFAULT_OPMODE;
44458
44459 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44460 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44461 + pax_open_kernel();
44462 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44463 + pax_close_kernel();
44464 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44465 } else {
44466 return -EIO;
44467 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44468 index b0c3de9..fc5857e 100644
44469 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44470 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44471 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44472 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
44473 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44474 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44475 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44476 + pax_open_kernel();
44477 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44478 + pax_close_kernel();
44479 } else if (priv_level == QLCNIC_PRIV_FUNC) {
44480 ahw->op_mode = QLCNIC_PRIV_FUNC;
44481 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44482 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44483 + pax_open_kernel();
44484 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44485 + pax_close_kernel();
44486 } else if (priv_level == QLCNIC_MGMT_FUNC) {
44487 ahw->op_mode = QLCNIC_MGMT_FUNC;
44488 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44489 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44490 + pax_open_kernel();
44491 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44492 + pax_close_kernel();
44493 } else {
44494 return -EIO;
44495 }
44496 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
44497 index 6acf82b..14b097e 100644
44498 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
44499 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
44500 @@ -206,10 +206,10 @@ int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *adapter)
44501 if (err) {
44502 dev_info(&adapter->pdev->dev,
44503 "Failed to set driver version in firmware\n");
44504 - return -EIO;
44505 + err = -EIO;
44506 }
44507 -
44508 - return 0;
44509 + qlcnic_free_mbx_args(&cmd);
44510 + return err;
44511 }
44512
44513 int
44514 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
44515 index d3f8797..82a03d3 100644
44516 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
44517 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
44518 @@ -262,7 +262,7 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr,
44519
44520 mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
44521 mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
44522 - memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
44523 + memcpy(mac_req->mac_addr, uaddr, ETH_ALEN);
44524
44525 vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
44526 vlan_req->vlan_id = cpu_to_le16(vlan_id);
44527 diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
44528 index 887aebe..9095ff9 100644
44529 --- a/drivers/net/ethernet/realtek/8139cp.c
44530 +++ b/drivers/net/ethernet/realtek/8139cp.c
44531 @@ -524,6 +524,7 @@ rx_status_loop:
44532 PCI_DMA_FROMDEVICE);
44533 if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
44534 dev->stats.rx_dropped++;
44535 + kfree_skb(new_skb);
44536 goto rx_next;
44537 }
44538
44539 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44540 index 393f961..d343034 100644
44541 --- a/drivers/net/ethernet/realtek/r8169.c
44542 +++ b/drivers/net/ethernet/realtek/r8169.c
44543 @@ -753,22 +753,22 @@ struct rtl8169_private {
44544 struct mdio_ops {
44545 void (*write)(struct rtl8169_private *, int, int);
44546 int (*read)(struct rtl8169_private *, int);
44547 - } mdio_ops;
44548 + } __no_const mdio_ops;
44549
44550 struct pll_power_ops {
44551 void (*down)(struct rtl8169_private *);
44552 void (*up)(struct rtl8169_private *);
44553 - } pll_power_ops;
44554 + } __no_const pll_power_ops;
44555
44556 struct jumbo_ops {
44557 void (*enable)(struct rtl8169_private *);
44558 void (*disable)(struct rtl8169_private *);
44559 - } jumbo_ops;
44560 + } __no_const jumbo_ops;
44561
44562 struct csi_ops {
44563 void (*write)(struct rtl8169_private *, int, int);
44564 u32 (*read)(struct rtl8169_private *, int);
44565 - } csi_ops;
44566 + } __no_const csi_ops;
44567
44568 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44569 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44570 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44571 index 9a95abf..36df7f9 100644
44572 --- a/drivers/net/ethernet/sfc/ptp.c
44573 +++ b/drivers/net/ethernet/sfc/ptp.c
44574 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44575 (u32)((u64)ptp->start.dma_addr >> 32));
44576
44577 /* Clear flag that signals MC ready */
44578 - ACCESS_ONCE(*start) = 0;
44579 + ACCESS_ONCE_RW(*start) = 0;
44580 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44581 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44582
44583 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44584 index 50617c5..b13724c 100644
44585 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44586 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44587 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44588
44589 writel(value, ioaddr + MMC_CNTRL);
44590
44591 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44592 - MMC_CNTRL, value);
44593 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44594 +// MMC_CNTRL, value);
44595 }
44596
44597 /* To mask all all interrupts.*/
44598 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44599 index e6fe0d8..2b7d752 100644
44600 --- a/drivers/net/hyperv/hyperv_net.h
44601 +++ b/drivers/net/hyperv/hyperv_net.h
44602 @@ -101,7 +101,7 @@ struct rndis_device {
44603
44604 enum rndis_device_state state;
44605 bool link_state;
44606 - atomic_t new_req_id;
44607 + atomic_unchecked_t new_req_id;
44608
44609 spinlock_t request_lock;
44610 struct list_head req_list;
44611 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44612 index 0775f0a..d4fb316 100644
44613 --- a/drivers/net/hyperv/rndis_filter.c
44614 +++ b/drivers/net/hyperv/rndis_filter.c
44615 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44616 * template
44617 */
44618 set = &rndis_msg->msg.set_req;
44619 - set->req_id = atomic_inc_return(&dev->new_req_id);
44620 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44621
44622 /* Add to the request list */
44623 spin_lock_irqsave(&dev->request_lock, flags);
44624 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44625
44626 /* Setup the rndis set */
44627 halt = &request->request_msg.msg.halt_req;
44628 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44629 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44630
44631 /* Ignore return since this msg is optional. */
44632 rndis_filter_send_request(dev, request);
44633 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44634 index bf0d55e..82bcfbd1 100644
44635 --- a/drivers/net/ieee802154/fakehard.c
44636 +++ b/drivers/net/ieee802154/fakehard.c
44637 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44638 phy->transmit_power = 0xbf;
44639
44640 dev->netdev_ops = &fake_ops;
44641 - dev->ml_priv = &fake_mlme;
44642 + dev->ml_priv = (void *)&fake_mlme;
44643
44644 priv = netdev_priv(dev);
44645 priv->phy = phy;
44646 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44647 index 6e91931..2b0ebe7 100644
44648 --- a/drivers/net/macvlan.c
44649 +++ b/drivers/net/macvlan.c
44650 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44651 int macvlan_link_register(struct rtnl_link_ops *ops)
44652 {
44653 /* common fields */
44654 - ops->priv_size = sizeof(struct macvlan_dev);
44655 - ops->validate = macvlan_validate;
44656 - ops->maxtype = IFLA_MACVLAN_MAX;
44657 - ops->policy = macvlan_policy;
44658 - ops->changelink = macvlan_changelink;
44659 - ops->get_size = macvlan_get_size;
44660 - ops->fill_info = macvlan_fill_info;
44661 + pax_open_kernel();
44662 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44663 + *(void **)&ops->validate = macvlan_validate;
44664 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44665 + *(const void **)&ops->policy = macvlan_policy;
44666 + *(void **)&ops->changelink = macvlan_changelink;
44667 + *(void **)&ops->get_size = macvlan_get_size;
44668 + *(void **)&ops->fill_info = macvlan_fill_info;
44669 + pax_close_kernel();
44670
44671 return rtnl_link_register(ops);
44672 };
44673 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44674 return NOTIFY_DONE;
44675 }
44676
44677 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44678 +static struct notifier_block macvlan_notifier_block = {
44679 .notifier_call = macvlan_device_event,
44680 };
44681
44682 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44683 index 523d6b2..5e16aa1 100644
44684 --- a/drivers/net/macvtap.c
44685 +++ b/drivers/net/macvtap.c
44686 @@ -1110,7 +1110,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44687 return NOTIFY_DONE;
44688 }
44689
44690 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44691 +static struct notifier_block macvtap_notifier_block = {
44692 .notifier_call = macvtap_device_event,
44693 };
44694
44695 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44696 index daec9b0..6428fcb 100644
44697 --- a/drivers/net/phy/mdio-bitbang.c
44698 +++ b/drivers/net/phy/mdio-bitbang.c
44699 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44700 struct mdiobb_ctrl *ctrl = bus->priv;
44701
44702 module_put(ctrl->ops->owner);
44703 + mdiobus_unregister(bus);
44704 mdiobus_free(bus);
44705 }
44706 EXPORT_SYMBOL(free_mdio_bitbang);
44707 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44708 index 72ff14b..11d442d 100644
44709 --- a/drivers/net/ppp/ppp_generic.c
44710 +++ b/drivers/net/ppp/ppp_generic.c
44711 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44712 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44713 struct ppp_stats stats;
44714 struct ppp_comp_stats cstats;
44715 - char *vers;
44716
44717 switch (cmd) {
44718 case SIOCGPPPSTATS:
44719 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44720 break;
44721
44722 case SIOCGPPPVER:
44723 - vers = PPP_VERSION;
44724 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44725 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44726 break;
44727 err = 0;
44728 break;
44729 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44730 index 1252d9c..80e660b 100644
44731 --- a/drivers/net/slip/slhc.c
44732 +++ b/drivers/net/slip/slhc.c
44733 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44734 register struct tcphdr *thp;
44735 register struct iphdr *ip;
44736 register struct cstate *cs;
44737 - int len, hdrlen;
44738 + long len, hdrlen;
44739 unsigned char *cp = icp;
44740
44741 /* We've got a compressed packet; read the change byte */
44742 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44743 index b305105..8ead6df 100644
44744 --- a/drivers/net/team/team.c
44745 +++ b/drivers/net/team/team.c
44746 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
44747 return NOTIFY_DONE;
44748 }
44749
44750 -static struct notifier_block team_notifier_block __read_mostly = {
44751 +static struct notifier_block team_notifier_block = {
44752 .notifier_call = team_device_event,
44753 };
44754
44755 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44756 index 2491eb2..1a453eb 100644
44757 --- a/drivers/net/tun.c
44758 +++ b/drivers/net/tun.c
44759 @@ -1076,8 +1076,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
44760 u32 rxhash;
44761
44762 if (!(tun->flags & TUN_NO_PI)) {
44763 - if ((len -= sizeof(pi)) > total_len)
44764 + if (len < sizeof(pi))
44765 return -EINVAL;
44766 + len -= sizeof(pi);
44767
44768 if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
44769 return -EFAULT;
44770 @@ -1085,8 +1086,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
44771 }
44772
44773 if (tun->flags & TUN_VNET_HDR) {
44774 - if ((len -= tun->vnet_hdr_sz) > total_len)
44775 + if (len < tun->vnet_hdr_sz)
44776 return -EINVAL;
44777 + len -= tun->vnet_hdr_sz;
44778
44779 if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
44780 return -EFAULT;
44781 @@ -1869,7 +1871,7 @@ unlock:
44782 }
44783
44784 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44785 - unsigned long arg, int ifreq_len)
44786 + unsigned long arg, size_t ifreq_len)
44787 {
44788 struct tun_file *tfile = file->private_data;
44789 struct tun_struct *tun;
44790 @@ -1881,6 +1883,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44791 int vnet_hdr_sz;
44792 int ret;
44793
44794 + if (ifreq_len > sizeof ifr)
44795 + return -EFAULT;
44796 +
44797 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44798 if (copy_from_user(&ifr, argp, ifreq_len))
44799 return -EFAULT;
44800 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44801 index cba1d46..f703766 100644
44802 --- a/drivers/net/usb/hso.c
44803 +++ b/drivers/net/usb/hso.c
44804 @@ -71,7 +71,7 @@
44805 #include <asm/byteorder.h>
44806 #include <linux/serial_core.h>
44807 #include <linux/serial.h>
44808 -
44809 +#include <asm/local.h>
44810
44811 #define MOD_AUTHOR "Option Wireless"
44812 #define MOD_DESCRIPTION "USB High Speed Option driver"
44813 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44814 struct urb *urb;
44815
44816 urb = serial->rx_urb[0];
44817 - if (serial->port.count > 0) {
44818 + if (atomic_read(&serial->port.count) > 0) {
44819 count = put_rxbuf_data(urb, serial);
44820 if (count == -1)
44821 return;
44822 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44823 DUMP1(urb->transfer_buffer, urb->actual_length);
44824
44825 /* Anyone listening? */
44826 - if (serial->port.count == 0)
44827 + if (atomic_read(&serial->port.count) == 0)
44828 return;
44829
44830 if (status == 0) {
44831 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44832 tty_port_tty_set(&serial->port, tty);
44833
44834 /* check for port already opened, if not set the termios */
44835 - serial->port.count++;
44836 - if (serial->port.count == 1) {
44837 + if (atomic_inc_return(&serial->port.count) == 1) {
44838 serial->rx_state = RX_IDLE;
44839 /* Force default termio settings */
44840 _hso_serial_set_termios(tty, NULL);
44841 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44842 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44843 if (result) {
44844 hso_stop_serial_device(serial->parent);
44845 - serial->port.count--;
44846 + atomic_dec(&serial->port.count);
44847 kref_put(&serial->parent->ref, hso_serial_ref_free);
44848 }
44849 } else {
44850 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44851
44852 /* reset the rts and dtr */
44853 /* do the actual close */
44854 - serial->port.count--;
44855 + atomic_dec(&serial->port.count);
44856
44857 - if (serial->port.count <= 0) {
44858 - serial->port.count = 0;
44859 + if (atomic_read(&serial->port.count) <= 0) {
44860 + atomic_set(&serial->port.count, 0);
44861 tty_port_tty_set(&serial->port, NULL);
44862 if (!usb_gone)
44863 hso_stop_serial_device(serial->parent);
44864 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44865
44866 /* the actual setup */
44867 spin_lock_irqsave(&serial->serial_lock, flags);
44868 - if (serial->port.count)
44869 + if (atomic_read(&serial->port.count))
44870 _hso_serial_set_termios(tty, old);
44871 else
44872 tty->termios = *old;
44873 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44874 D1("Pending read interrupt on port %d\n", i);
44875 spin_lock(&serial->serial_lock);
44876 if (serial->rx_state == RX_IDLE &&
44877 - serial->port.count > 0) {
44878 + atomic_read(&serial->port.count) > 0) {
44879 /* Setup and send a ctrl req read on
44880 * port i */
44881 if (!serial->rx_urb_filled[0]) {
44882 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
44883 /* Start all serial ports */
44884 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44885 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44886 - if (dev2ser(serial_table[i])->port.count) {
44887 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44888 result =
44889 hso_start_serial_device(serial_table[i], GFP_NOIO);
44890 hso_kick_transmit(dev2ser(serial_table[i]));
44891 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44892 index a79e9d3..78cd4fa 100644
44893 --- a/drivers/net/usb/sierra_net.c
44894 +++ b/drivers/net/usb/sierra_net.c
44895 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44896 /* atomic counter partially included in MAC address to make sure 2 devices
44897 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44898 */
44899 -static atomic_t iface_counter = ATOMIC_INIT(0);
44900 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44901
44902 /*
44903 * SYNC Timer Delay definition used to set the expiry time
44904 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44905 dev->net->netdev_ops = &sierra_net_device_ops;
44906
44907 /* change MAC addr to include, ifacenum, and to be unique */
44908 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44909 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44910 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44911
44912 /* we will have to manufacture ethernet headers, prepare template */
44913 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44914 index 57325f3..36b181f 100644
44915 --- a/drivers/net/vxlan.c
44916 +++ b/drivers/net/vxlan.c
44917 @@ -1579,7 +1579,7 @@ nla_put_failure:
44918 return -EMSGSIZE;
44919 }
44920
44921 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44922 +static struct rtnl_link_ops vxlan_link_ops = {
44923 .kind = "vxlan",
44924 .maxtype = IFLA_VXLAN_MAX,
44925 .policy = vxlan_policy,
44926 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44927 index 34c8a33..3261fdc 100644
44928 --- a/drivers/net/wireless/at76c50x-usb.c
44929 +++ b/drivers/net/wireless/at76c50x-usb.c
44930 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44931 }
44932
44933 /* Convert timeout from the DFU status to jiffies */
44934 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44935 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44936 {
44937 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44938 | (s->poll_timeout[1] << 8)
44939 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44940 index 8d78253..bebbb68 100644
44941 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44942 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44943 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44944 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44945 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44946
44947 - ACCESS_ONCE(ads->ds_link) = i->link;
44948 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44949 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44950 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44951
44952 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44953 ctl6 = SM(i->keytype, AR_EncrType);
44954 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44955
44956 if ((i->is_first || i->is_last) &&
44957 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44958 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44959 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44960 | set11nTries(i->rates, 1)
44961 | set11nTries(i->rates, 2)
44962 | set11nTries(i->rates, 3)
44963 | (i->dur_update ? AR_DurUpdateEna : 0)
44964 | SM(0, AR_BurstDur);
44965
44966 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44967 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44968 | set11nRate(i->rates, 1)
44969 | set11nRate(i->rates, 2)
44970 | set11nRate(i->rates, 3);
44971 } else {
44972 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44973 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44974 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44975 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44976 }
44977
44978 if (!i->is_first) {
44979 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44980 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44981 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44982 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44983 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44984 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44985 return;
44986 }
44987
44988 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44989 break;
44990 }
44991
44992 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44993 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44994 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44995 | SM(i->txpower, AR_XmitPower)
44996 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44997 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44998 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44999 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
45000
45001 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
45002 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
45003 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
45004 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
45005
45006 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
45007 return;
45008
45009 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
45010 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
45011 | set11nPktDurRTSCTS(i->rates, 1);
45012
45013 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
45014 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
45015 | set11nPktDurRTSCTS(i->rates, 3);
45016
45017 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
45018 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
45019 | set11nRateFlags(i->rates, 1)
45020 | set11nRateFlags(i->rates, 2)
45021 | set11nRateFlags(i->rates, 3)
45022 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45023 index 301bf72..3f5654f 100644
45024 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45025 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45026 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45027 (i->qcu << AR_TxQcuNum_S) | desc_len;
45028
45029 checksum += val;
45030 - ACCESS_ONCE(ads->info) = val;
45031 + ACCESS_ONCE_RW(ads->info) = val;
45032
45033 checksum += i->link;
45034 - ACCESS_ONCE(ads->link) = i->link;
45035 + ACCESS_ONCE_RW(ads->link) = i->link;
45036
45037 checksum += i->buf_addr[0];
45038 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
45039 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
45040 checksum += i->buf_addr[1];
45041 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
45042 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
45043 checksum += i->buf_addr[2];
45044 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
45045 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
45046 checksum += i->buf_addr[3];
45047 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
45048 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
45049
45050 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
45051 - ACCESS_ONCE(ads->ctl3) = val;
45052 + ACCESS_ONCE_RW(ads->ctl3) = val;
45053 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
45054 - ACCESS_ONCE(ads->ctl5) = val;
45055 + ACCESS_ONCE_RW(ads->ctl5) = val;
45056 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
45057 - ACCESS_ONCE(ads->ctl7) = val;
45058 + ACCESS_ONCE_RW(ads->ctl7) = val;
45059 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
45060 - ACCESS_ONCE(ads->ctl9) = val;
45061 + ACCESS_ONCE_RW(ads->ctl9) = val;
45062
45063 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
45064 - ACCESS_ONCE(ads->ctl10) = checksum;
45065 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
45066
45067 if (i->is_first || i->is_last) {
45068 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
45069 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
45070 | set11nTries(i->rates, 1)
45071 | set11nTries(i->rates, 2)
45072 | set11nTries(i->rates, 3)
45073 | (i->dur_update ? AR_DurUpdateEna : 0)
45074 | SM(0, AR_BurstDur);
45075
45076 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
45077 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
45078 | set11nRate(i->rates, 1)
45079 | set11nRate(i->rates, 2)
45080 | set11nRate(i->rates, 3);
45081 } else {
45082 - ACCESS_ONCE(ads->ctl13) = 0;
45083 - ACCESS_ONCE(ads->ctl14) = 0;
45084 + ACCESS_ONCE_RW(ads->ctl13) = 0;
45085 + ACCESS_ONCE_RW(ads->ctl14) = 0;
45086 }
45087
45088 ads->ctl20 = 0;
45089 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45090
45091 ctl17 = SM(i->keytype, AR_EncrType);
45092 if (!i->is_first) {
45093 - ACCESS_ONCE(ads->ctl11) = 0;
45094 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
45095 - ACCESS_ONCE(ads->ctl15) = 0;
45096 - ACCESS_ONCE(ads->ctl16) = 0;
45097 - ACCESS_ONCE(ads->ctl17) = ctl17;
45098 - ACCESS_ONCE(ads->ctl18) = 0;
45099 - ACCESS_ONCE(ads->ctl19) = 0;
45100 + ACCESS_ONCE_RW(ads->ctl11) = 0;
45101 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
45102 + ACCESS_ONCE_RW(ads->ctl15) = 0;
45103 + ACCESS_ONCE_RW(ads->ctl16) = 0;
45104 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
45105 + ACCESS_ONCE_RW(ads->ctl18) = 0;
45106 + ACCESS_ONCE_RW(ads->ctl19) = 0;
45107 return;
45108 }
45109
45110 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45111 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45112 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
45113 | SM(i->txpower, AR_XmitPower)
45114 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
45115 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45116 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
45117 ctl12 |= SM(val, AR_PAPRDChainMask);
45118
45119 - ACCESS_ONCE(ads->ctl12) = ctl12;
45120 - ACCESS_ONCE(ads->ctl17) = ctl17;
45121 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
45122 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
45123
45124 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45125 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45126 | set11nPktDurRTSCTS(i->rates, 1);
45127
45128 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45129 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45130 | set11nPktDurRTSCTS(i->rates, 3);
45131
45132 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
45133 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
45134 | set11nRateFlags(i->rates, 1)
45135 | set11nRateFlags(i->rates, 2)
45136 | set11nRateFlags(i->rates, 3)
45137 | SM(i->rtscts_rate, AR_RTSCTSRate);
45138
45139 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
45140 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
45141 }
45142
45143 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
45144 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
45145 index ae30343..a117806 100644
45146 --- a/drivers/net/wireless/ath/ath9k/hw.h
45147 +++ b/drivers/net/wireless/ath/ath9k/hw.h
45148 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
45149
45150 /* ANI */
45151 void (*ani_cache_ini_regs)(struct ath_hw *ah);
45152 -};
45153 +} __no_const;
45154
45155 /**
45156 * struct ath_spec_scan - parameters for Atheros spectral scan
45157 @@ -721,7 +721,7 @@ struct ath_hw_ops {
45158 struct ath_spec_scan *param);
45159 void (*spectral_scan_trigger)(struct ath_hw *ah);
45160 void (*spectral_scan_wait)(struct ath_hw *ah);
45161 -};
45162 +} __no_const;
45163
45164 struct ath_nf_limits {
45165 s16 max;
45166 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45167 index b37a582..680835d 100644
45168 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45169 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45170 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45171 */
45172 if (il3945_mod_params.disable_hw_scan) {
45173 D_INFO("Disabling hw_scan\n");
45174 - il3945_mac_ops.hw_scan = NULL;
45175 + pax_open_kernel();
45176 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45177 + pax_close_kernel();
45178 }
45179
45180 D_INFO("*** LOAD DRIVER ***\n");
45181 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45182 index d532948..e0d8bb1 100644
45183 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45184 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45185 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45186 {
45187 struct iwl_priv *priv = file->private_data;
45188 char buf[64];
45189 - int buf_size;
45190 + size_t buf_size;
45191 u32 offset, len;
45192
45193 memset(buf, 0, sizeof(buf));
45194 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45195 struct iwl_priv *priv = file->private_data;
45196
45197 char buf[8];
45198 - int buf_size;
45199 + size_t buf_size;
45200 u32 reset_flag;
45201
45202 memset(buf, 0, sizeof(buf));
45203 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45204 {
45205 struct iwl_priv *priv = file->private_data;
45206 char buf[8];
45207 - int buf_size;
45208 + size_t buf_size;
45209 int ht40;
45210
45211 memset(buf, 0, sizeof(buf));
45212 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45213 {
45214 struct iwl_priv *priv = file->private_data;
45215 char buf[8];
45216 - int buf_size;
45217 + size_t buf_size;
45218 int value;
45219
45220 memset(buf, 0, sizeof(buf));
45221 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45222 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45223 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45224
45225 -static const char *fmt_value = " %-30s %10u\n";
45226 -static const char *fmt_hex = " %-30s 0x%02X\n";
45227 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45228 -static const char *fmt_header =
45229 +static const char fmt_value[] = " %-30s %10u\n";
45230 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45231 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45232 +static const char fmt_header[] =
45233 "%-32s current cumulative delta max\n";
45234
45235 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45236 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45237 {
45238 struct iwl_priv *priv = file->private_data;
45239 char buf[8];
45240 - int buf_size;
45241 + size_t buf_size;
45242 int clear;
45243
45244 memset(buf, 0, sizeof(buf));
45245 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45246 {
45247 struct iwl_priv *priv = file->private_data;
45248 char buf[8];
45249 - int buf_size;
45250 + size_t buf_size;
45251 int trace;
45252
45253 memset(buf, 0, sizeof(buf));
45254 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45255 {
45256 struct iwl_priv *priv = file->private_data;
45257 char buf[8];
45258 - int buf_size;
45259 + size_t buf_size;
45260 int missed;
45261
45262 memset(buf, 0, sizeof(buf));
45263 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45264
45265 struct iwl_priv *priv = file->private_data;
45266 char buf[8];
45267 - int buf_size;
45268 + size_t buf_size;
45269 int plcp;
45270
45271 memset(buf, 0, sizeof(buf));
45272 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45273
45274 struct iwl_priv *priv = file->private_data;
45275 char buf[8];
45276 - int buf_size;
45277 + size_t buf_size;
45278 int flush;
45279
45280 memset(buf, 0, sizeof(buf));
45281 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45282
45283 struct iwl_priv *priv = file->private_data;
45284 char buf[8];
45285 - int buf_size;
45286 + size_t buf_size;
45287 int rts;
45288
45289 if (!priv->cfg->ht_params)
45290 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45291 {
45292 struct iwl_priv *priv = file->private_data;
45293 char buf[8];
45294 - int buf_size;
45295 + size_t buf_size;
45296
45297 memset(buf, 0, sizeof(buf));
45298 buf_size = min(count, sizeof(buf) - 1);
45299 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45300 struct iwl_priv *priv = file->private_data;
45301 u32 event_log_flag;
45302 char buf[8];
45303 - int buf_size;
45304 + size_t buf_size;
45305
45306 /* check that the interface is up */
45307 if (!iwl_is_ready(priv))
45308 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45309 struct iwl_priv *priv = file->private_data;
45310 char buf[8];
45311 u32 calib_disabled;
45312 - int buf_size;
45313 + size_t buf_size;
45314
45315 memset(buf, 0, sizeof(buf));
45316 buf_size = min(count, sizeof(buf) - 1);
45317 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45318 index a8afc7b..de058b2 100644
45319 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45320 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45321 @@ -1189,7 +1189,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45322 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45323 {
45324 struct iwl_nvm_data *data = priv->nvm_data;
45325 - char *debug_msg;
45326 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45327
45328 if (data->sku_cap_11n_enable &&
45329 !priv->cfg->ht_params) {
45330 @@ -1203,7 +1203,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45331 return -EINVAL;
45332 }
45333
45334 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45335 IWL_DEBUG_INFO(priv, debug_msg,
45336 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45337 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45338 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45339 index aeb70e1..d7b5bb5 100644
45340 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45341 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45342 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45343 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45344
45345 char buf[8];
45346 - int buf_size;
45347 + size_t buf_size;
45348 u32 reset_flag;
45349
45350 memset(buf, 0, sizeof(buf));
45351 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45352 {
45353 struct iwl_trans *trans = file->private_data;
45354 char buf[8];
45355 - int buf_size;
45356 + size_t buf_size;
45357 int csr;
45358
45359 memset(buf, 0, sizeof(buf));
45360 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45361 index cb34c78..9fec0dc 100644
45362 --- a/drivers/net/wireless/mac80211_hwsim.c
45363 +++ b/drivers/net/wireless/mac80211_hwsim.c
45364 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45365
45366 if (channels > 1) {
45367 hwsim_if_comb.num_different_channels = channels;
45368 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45369 - mac80211_hwsim_ops.cancel_hw_scan =
45370 - mac80211_hwsim_cancel_hw_scan;
45371 - mac80211_hwsim_ops.sw_scan_start = NULL;
45372 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45373 - mac80211_hwsim_ops.remain_on_channel =
45374 - mac80211_hwsim_roc;
45375 - mac80211_hwsim_ops.cancel_remain_on_channel =
45376 - mac80211_hwsim_croc;
45377 - mac80211_hwsim_ops.add_chanctx =
45378 - mac80211_hwsim_add_chanctx;
45379 - mac80211_hwsim_ops.remove_chanctx =
45380 - mac80211_hwsim_remove_chanctx;
45381 - mac80211_hwsim_ops.change_chanctx =
45382 - mac80211_hwsim_change_chanctx;
45383 - mac80211_hwsim_ops.assign_vif_chanctx =
45384 - mac80211_hwsim_assign_vif_chanctx;
45385 - mac80211_hwsim_ops.unassign_vif_chanctx =
45386 - mac80211_hwsim_unassign_vif_chanctx;
45387 + pax_open_kernel();
45388 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45389 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45390 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45391 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45392 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45393 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45394 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45395 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45396 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45397 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45398 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45399 + pax_close_kernel();
45400 }
45401
45402 spin_lock_init(&hwsim_radio_lock);
45403 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45404 index 8169a85..7fa3b47 100644
45405 --- a/drivers/net/wireless/rndis_wlan.c
45406 +++ b/drivers/net/wireless/rndis_wlan.c
45407 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45408
45409 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45410
45411 - if (rts_threshold < 0 || rts_threshold > 2347)
45412 + if (rts_threshold > 2347)
45413 rts_threshold = 2347;
45414
45415 tmp = cpu_to_le32(rts_threshold);
45416 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45417 index 7510723..5ba37f5 100644
45418 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45419 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45420 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45421 * for hardware which doesn't support hardware
45422 * sequence counting.
45423 */
45424 - atomic_t seqno;
45425 + atomic_unchecked_t seqno;
45426 };
45427
45428 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45429 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45430 index d955741..8730748 100644
45431 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45432 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45433 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45434 * sequence counter given by mac80211.
45435 */
45436 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45437 - seqno = atomic_add_return(0x10, &intf->seqno);
45438 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45439 else
45440 - seqno = atomic_read(&intf->seqno);
45441 + seqno = atomic_read_unchecked(&intf->seqno);
45442
45443 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45444 hdr->seq_ctrl |= cpu_to_le16(seqno);
45445 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45446 index e2b3d9c..67a5184 100644
45447 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45448 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45449 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45450
45451 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45452
45453 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45454 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45455 + pax_open_kernel();
45456 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45457 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45458 + pax_close_kernel();
45459
45460 wl1251_info("using dedicated interrupt line");
45461 } else {
45462 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45463 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45464 + pax_open_kernel();
45465 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45466 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45467 + pax_close_kernel();
45468
45469 wl1251_info("using SDIO interrupt");
45470 }
45471 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45472 index 1c627da..69f7d17 100644
45473 --- a/drivers/net/wireless/ti/wl12xx/main.c
45474 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45475 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45476 sizeof(wl->conf.mem));
45477
45478 /* read data preparation is only needed by wl127x */
45479 - wl->ops->prepare_read = wl127x_prepare_read;
45480 + pax_open_kernel();
45481 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45482 + pax_close_kernel();
45483
45484 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45485 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45486 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45487 sizeof(wl->conf.mem));
45488
45489 /* read data preparation is only needed by wl127x */
45490 - wl->ops->prepare_read = wl127x_prepare_read;
45491 + pax_open_kernel();
45492 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45493 + pax_close_kernel();
45494
45495 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45496 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45497 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45498 index 9fa692d..b31fee0 100644
45499 --- a/drivers/net/wireless/ti/wl18xx/main.c
45500 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45501 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45502 }
45503
45504 if (!checksum_param) {
45505 - wl18xx_ops.set_rx_csum = NULL;
45506 - wl18xx_ops.init_vif = NULL;
45507 + pax_open_kernel();
45508 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45509 + *(void **)&wl18xx_ops.init_vif = NULL;
45510 + pax_close_kernel();
45511 }
45512
45513 /* Enable 11a Band only if we have 5G antennas */
45514 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45515 index 7ef0b4a..ff65c28 100644
45516 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45517 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45518 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45519 {
45520 struct zd_usb *usb = urb->context;
45521 struct zd_usb_interrupt *intr = &usb->intr;
45522 - int len;
45523 + unsigned int len;
45524 u16 int_num;
45525
45526 ZD_ASSERT(in_interrupt());
45527 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45528 index d93b2b6..ae50401 100644
45529 --- a/drivers/oprofile/buffer_sync.c
45530 +++ b/drivers/oprofile/buffer_sync.c
45531 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45532 if (cookie == NO_COOKIE)
45533 offset = pc;
45534 if (cookie == INVALID_COOKIE) {
45535 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45536 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45537 offset = pc;
45538 }
45539 if (cookie != last_cookie) {
45540 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45541 /* add userspace sample */
45542
45543 if (!mm) {
45544 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45545 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45546 return 0;
45547 }
45548
45549 cookie = lookup_dcookie(mm, s->eip, &offset);
45550
45551 if (cookie == INVALID_COOKIE) {
45552 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45553 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45554 return 0;
45555 }
45556
45557 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45558 /* ignore backtraces if failed to add a sample */
45559 if (state == sb_bt_start) {
45560 state = sb_bt_ignore;
45561 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45562 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45563 }
45564 }
45565 release_mm(mm);
45566 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45567 index c0cc4e7..44d4e54 100644
45568 --- a/drivers/oprofile/event_buffer.c
45569 +++ b/drivers/oprofile/event_buffer.c
45570 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45571 }
45572
45573 if (buffer_pos == buffer_size) {
45574 - atomic_inc(&oprofile_stats.event_lost_overflow);
45575 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45576 return;
45577 }
45578
45579 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45580 index ed2c3ec..deda85a 100644
45581 --- a/drivers/oprofile/oprof.c
45582 +++ b/drivers/oprofile/oprof.c
45583 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45584 if (oprofile_ops.switch_events())
45585 return;
45586
45587 - atomic_inc(&oprofile_stats.multiplex_counter);
45588 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45589 start_switch_worker();
45590 }
45591
45592 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45593 index 84a208d..d61b0a1 100644
45594 --- a/drivers/oprofile/oprofile_files.c
45595 +++ b/drivers/oprofile/oprofile_files.c
45596 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45597
45598 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45599
45600 -static ssize_t timeout_read(struct file *file, char __user *buf,
45601 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45602 size_t count, loff_t *offset)
45603 {
45604 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45605 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45606 index 917d28e..d62d981 100644
45607 --- a/drivers/oprofile/oprofile_stats.c
45608 +++ b/drivers/oprofile/oprofile_stats.c
45609 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45610 cpu_buf->sample_invalid_eip = 0;
45611 }
45612
45613 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45614 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45615 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45616 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45617 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45618 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45619 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45620 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45621 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45622 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45623 }
45624
45625
45626 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45627 index 38b6fc0..b5cbfce 100644
45628 --- a/drivers/oprofile/oprofile_stats.h
45629 +++ b/drivers/oprofile/oprofile_stats.h
45630 @@ -13,11 +13,11 @@
45631 #include <linux/atomic.h>
45632
45633 struct oprofile_stat_struct {
45634 - atomic_t sample_lost_no_mm;
45635 - atomic_t sample_lost_no_mapping;
45636 - atomic_t bt_lost_no_mapping;
45637 - atomic_t event_lost_overflow;
45638 - atomic_t multiplex_counter;
45639 + atomic_unchecked_t sample_lost_no_mm;
45640 + atomic_unchecked_t sample_lost_no_mapping;
45641 + atomic_unchecked_t bt_lost_no_mapping;
45642 + atomic_unchecked_t event_lost_overflow;
45643 + atomic_unchecked_t multiplex_counter;
45644 };
45645
45646 extern struct oprofile_stat_struct oprofile_stats;
45647 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45648 index 7c12d9c..558bf3bb 100644
45649 --- a/drivers/oprofile/oprofilefs.c
45650 +++ b/drivers/oprofile/oprofilefs.c
45651 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45652
45653
45654 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45655 - char const *name, atomic_t *val)
45656 + char const *name, atomic_unchecked_t *val)
45657 {
45658 return __oprofilefs_create_file(sb, root, name,
45659 &atomic_ro_fops, 0444, val);
45660 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45661 index 93404f7..4a313d8 100644
45662 --- a/drivers/oprofile/timer_int.c
45663 +++ b/drivers/oprofile/timer_int.c
45664 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
45665 return NOTIFY_OK;
45666 }
45667
45668 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45669 +static struct notifier_block oprofile_cpu_notifier = {
45670 .notifier_call = oprofile_cpu_notify,
45671 };
45672
45673 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45674 index 92ed045..62d39bd7 100644
45675 --- a/drivers/parport/procfs.c
45676 +++ b/drivers/parport/procfs.c
45677 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45678
45679 *ppos += len;
45680
45681 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45682 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45683 }
45684
45685 #ifdef CONFIG_PARPORT_1284
45686 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45687
45688 *ppos += len;
45689
45690 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45691 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45692 }
45693 #endif /* IEEE1284.3 support. */
45694
45695 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45696 index c35e8ad..fc33beb 100644
45697 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45698 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45699 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45700 goto init_cleanup;
45701 }
45702
45703 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45704 + pax_open_kernel();
45705 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45706 + pax_close_kernel();
45707 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45708
45709 return retval;
45710 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45711 index a6a71c4..c91097b 100644
45712 --- a/drivers/pci/hotplug/cpcihp_generic.c
45713 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45714 @@ -73,7 +73,6 @@ static u16 port;
45715 static unsigned int enum_bit;
45716 static u8 enum_mask;
45717
45718 -static struct cpci_hp_controller_ops generic_hpc_ops;
45719 static struct cpci_hp_controller generic_hpc;
45720
45721 static int __init validate_parameters(void)
45722 @@ -139,6 +138,10 @@ static int query_enum(void)
45723 return ((value & enum_mask) == enum_mask);
45724 }
45725
45726 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45727 + .query_enum = query_enum,
45728 +};
45729 +
45730 static int __init cpcihp_generic_init(void)
45731 {
45732 int status;
45733 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45734 pci_dev_put(dev);
45735
45736 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45737 - generic_hpc_ops.query_enum = query_enum;
45738 generic_hpc.ops = &generic_hpc_ops;
45739
45740 status = cpci_hp_register_controller(&generic_hpc);
45741 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45742 index 449b4bb..257e2e8 100644
45743 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45744 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45745 @@ -59,7 +59,6 @@
45746 /* local variables */
45747 static bool debug;
45748 static bool poll;
45749 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45750 static struct cpci_hp_controller zt5550_hpc;
45751
45752 /* Primary cPCI bus bridge device */
45753 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45754 return 0;
45755 }
45756
45757 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45758 + .query_enum = zt5550_hc_query_enum,
45759 +};
45760 +
45761 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45762 {
45763 int status;
45764 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45765 dbg("returned from zt5550_hc_config");
45766
45767 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45768 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45769 zt5550_hpc.ops = &zt5550_hpc_ops;
45770 if(!poll) {
45771 zt5550_hpc.irq = hc_dev->irq;
45772 zt5550_hpc.irq_flags = IRQF_SHARED;
45773 zt5550_hpc.dev_id = hc_dev;
45774
45775 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45776 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45777 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45778 + pax_open_kernel();
45779 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45780 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45781 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45782 + pax_open_kernel();
45783 } else {
45784 info("using ENUM# polling mode");
45785 }
45786 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45787 index 76ba8a1..20ca857 100644
45788 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45789 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45790 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45791
45792 void compaq_nvram_init (void __iomem *rom_start)
45793 {
45794 +
45795 +#ifndef CONFIG_PAX_KERNEXEC
45796 if (rom_start) {
45797 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45798 }
45799 +#endif
45800 +
45801 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45802
45803 /* initialize our int15 lock */
45804 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45805 index ec20f74..c1d961e 100644
45806 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45807 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45808 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45809 return -EINVAL;
45810 }
45811
45812 - slot->ops->owner = owner;
45813 - slot->ops->mod_name = mod_name;
45814 + pax_open_kernel();
45815 + *(struct module **)&slot->ops->owner = owner;
45816 + *(const char **)&slot->ops->mod_name = mod_name;
45817 + pax_close_kernel();
45818
45819 mutex_lock(&pci_hp_mutex);
45820 /*
45821 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45822 index 7d72c5e..edce02c 100644
45823 --- a/drivers/pci/hotplug/pciehp_core.c
45824 +++ b/drivers/pci/hotplug/pciehp_core.c
45825 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45826 struct slot *slot = ctrl->slot;
45827 struct hotplug_slot *hotplug = NULL;
45828 struct hotplug_slot_info *info = NULL;
45829 - struct hotplug_slot_ops *ops = NULL;
45830 + hotplug_slot_ops_no_const *ops = NULL;
45831 char name[SLOT_NAME_SIZE];
45832 int retval = -ENOMEM;
45833
45834 diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
45835 index 5127f3f..b225573 100644
45836 --- a/drivers/pci/hotplug/pciehp_hpc.c
45837 +++ b/drivers/pci/hotplug/pciehp_hpc.c
45838 @@ -773,14 +773,12 @@ static void pcie_shutdown_notification(struct controller *ctrl)
45839 static int pcie_init_slot(struct controller *ctrl)
45840 {
45841 struct slot *slot;
45842 - char name[32];
45843
45844 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
45845 if (!slot)
45846 return -ENOMEM;
45847
45848 - snprintf(name, sizeof(name), "pciehp-%u", PSN(ctrl));
45849 - slot->wq = alloc_workqueue(name, 0, 0);
45850 + slot->wq = alloc_workqueue("pciehp-%u", 0, 0, PSN(ctrl));
45851 if (!slot->wq)
45852 goto abort;
45853
45854 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45855 index 5b4a9d9..cd5ac1f 100644
45856 --- a/drivers/pci/pci-sysfs.c
45857 +++ b/drivers/pci/pci-sysfs.c
45858 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45859 {
45860 /* allocate attribute structure, piggyback attribute name */
45861 int name_len = write_combine ? 13 : 10;
45862 - struct bin_attribute *res_attr;
45863 + bin_attribute_no_const *res_attr;
45864 int retval;
45865
45866 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45867 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45868 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45869 {
45870 int retval;
45871 - struct bin_attribute *attr;
45872 + bin_attribute_no_const *attr;
45873
45874 /* If the device has VPD, try to expose it in sysfs. */
45875 if (dev->vpd) {
45876 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45877 {
45878 int retval;
45879 int rom_size = 0;
45880 - struct bin_attribute *attr;
45881 + bin_attribute_no_const *attr;
45882
45883 if (!sysfs_initialized)
45884 return -EACCES;
45885 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45886 index d1182c4..2a138ec 100644
45887 --- a/drivers/pci/pci.h
45888 +++ b/drivers/pci/pci.h
45889 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45890 struct pci_vpd {
45891 unsigned int len;
45892 const struct pci_vpd_ops *ops;
45893 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45894 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45895 };
45896
45897 int pci_vpd_pci22_init(struct pci_dev *dev);
45898 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45899 index d320df6..ca9a8f6 100644
45900 --- a/drivers/pci/pcie/aspm.c
45901 +++ b/drivers/pci/pcie/aspm.c
45902 @@ -27,9 +27,9 @@
45903 #define MODULE_PARAM_PREFIX "pcie_aspm."
45904
45905 /* Note: those are not register definitions */
45906 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45907 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45908 -#define ASPM_STATE_L1 (4) /* L1 state */
45909 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45910 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45911 +#define ASPM_STATE_L1 (4U) /* L1 state */
45912 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45913 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45914
45915 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45916 index ea37072..10e58e56 100644
45917 --- a/drivers/pci/probe.c
45918 +++ b/drivers/pci/probe.c
45919 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45920 struct pci_bus_region region;
45921 bool bar_too_big = false, bar_disabled = false;
45922
45923 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45924 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45925
45926 /* No printks while decoding is disabled! */
45927 if (!dev->mmio_always_on) {
45928 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45929 index 0812608..b04018c4 100644
45930 --- a/drivers/pci/proc.c
45931 +++ b/drivers/pci/proc.c
45932 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45933 static int __init pci_proc_init(void)
45934 {
45935 struct pci_dev *dev = NULL;
45936 +
45937 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45938 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45939 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45940 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45941 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45942 +#endif
45943 +#else
45944 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45945 +#endif
45946 proc_create("devices", 0, proc_bus_pci_dir,
45947 &proc_bus_pci_dev_operations);
45948 proc_initialized = 1;
45949 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45950 index 3e5b4497..dcdfb70 100644
45951 --- a/drivers/platform/x86/chromeos_laptop.c
45952 +++ b/drivers/platform/x86/chromeos_laptop.c
45953 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45954 return 0;
45955 }
45956
45957 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45958 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45959 {
45960 .ident = "Samsung Series 5 550 - Touchpad",
45961 .matches = {
45962 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45963 index 6b22938..bc9700e 100644
45964 --- a/drivers/platform/x86/msi-laptop.c
45965 +++ b/drivers/platform/x86/msi-laptop.c
45966 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45967
45968 if (!quirks->ec_read_only) {
45969 /* allow userland write sysfs file */
45970 - dev_attr_bluetooth.store = store_bluetooth;
45971 - dev_attr_wlan.store = store_wlan;
45972 - dev_attr_threeg.store = store_threeg;
45973 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45974 - dev_attr_wlan.attr.mode |= S_IWUSR;
45975 - dev_attr_threeg.attr.mode |= S_IWUSR;
45976 + pax_open_kernel();
45977 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45978 + *(void **)&dev_attr_wlan.store = store_wlan;
45979 + *(void **)&dev_attr_threeg.store = store_threeg;
45980 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45981 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45982 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45983 + pax_close_kernel();
45984 }
45985
45986 /* disable hardware control by fn key */
45987 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45988 index 2ac045f..39c443d 100644
45989 --- a/drivers/platform/x86/sony-laptop.c
45990 +++ b/drivers/platform/x86/sony-laptop.c
45991 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45992 }
45993
45994 /* High speed charging function */
45995 -static struct device_attribute *hsc_handle;
45996 +static device_attribute_no_const *hsc_handle;
45997
45998 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45999 struct device_attribute *attr,
46000 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
46001 index 54d31c0..3f896d3 100644
46002 --- a/drivers/platform/x86/thinkpad_acpi.c
46003 +++ b/drivers/platform/x86/thinkpad_acpi.c
46004 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
46005 return 0;
46006 }
46007
46008 -void static hotkey_mask_warn_incomplete_mask(void)
46009 +static void hotkey_mask_warn_incomplete_mask(void)
46010 {
46011 /* log only what the user can fix... */
46012 const u32 wantedmask = hotkey_driver_mask &
46013 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
46014 }
46015 }
46016
46017 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46018 - struct tp_nvram_state *newn,
46019 - const u32 event_mask)
46020 -{
46021 -
46022 #define TPACPI_COMPARE_KEY(__scancode, __member) \
46023 do { \
46024 if ((event_mask & (1 << __scancode)) && \
46025 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46026 tpacpi_hotkey_send_key(__scancode); \
46027 } while (0)
46028
46029 - void issue_volchange(const unsigned int oldvol,
46030 - const unsigned int newvol)
46031 - {
46032 - unsigned int i = oldvol;
46033 +static void issue_volchange(const unsigned int oldvol,
46034 + const unsigned int newvol,
46035 + const u32 event_mask)
46036 +{
46037 + unsigned int i = oldvol;
46038
46039 - while (i > newvol) {
46040 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
46041 - i--;
46042 - }
46043 - while (i < newvol) {
46044 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
46045 - i++;
46046 - }
46047 + while (i > newvol) {
46048 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
46049 + i--;
46050 }
46051 + while (i < newvol) {
46052 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
46053 + i++;
46054 + }
46055 +}
46056
46057 - void issue_brightnesschange(const unsigned int oldbrt,
46058 - const unsigned int newbrt)
46059 - {
46060 - unsigned int i = oldbrt;
46061 +static void issue_brightnesschange(const unsigned int oldbrt,
46062 + const unsigned int newbrt,
46063 + const u32 event_mask)
46064 +{
46065 + unsigned int i = oldbrt;
46066
46067 - while (i > newbrt) {
46068 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
46069 - i--;
46070 - }
46071 - while (i < newbrt) {
46072 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46073 - i++;
46074 - }
46075 + while (i > newbrt) {
46076 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
46077 + i--;
46078 + }
46079 + while (i < newbrt) {
46080 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46081 + i++;
46082 }
46083 +}
46084
46085 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46086 + struct tp_nvram_state *newn,
46087 + const u32 event_mask)
46088 +{
46089 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
46090 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
46091 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
46092 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46093 oldn->volume_level != newn->volume_level) {
46094 /* recently muted, or repeated mute keypress, or
46095 * multiple presses ending in mute */
46096 - issue_volchange(oldn->volume_level, newn->volume_level);
46097 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
46098 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
46099 }
46100 } else {
46101 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46102 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
46103 }
46104 if (oldn->volume_level != newn->volume_level) {
46105 - issue_volchange(oldn->volume_level, newn->volume_level);
46106 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
46107 } else if (oldn->volume_toggle != newn->volume_toggle) {
46108 /* repeated vol up/down keypress at end of scale ? */
46109 if (newn->volume_level == 0)
46110 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46111 /* handle brightness */
46112 if (oldn->brightness_level != newn->brightness_level) {
46113 issue_brightnesschange(oldn->brightness_level,
46114 - newn->brightness_level);
46115 + newn->brightness_level,
46116 + event_mask);
46117 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
46118 /* repeated key presses that didn't change state */
46119 if (newn->brightness_level == 0)
46120 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46121 && !tp_features.bright_unkfw)
46122 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46123 }
46124 +}
46125
46126 #undef TPACPI_COMPARE_KEY
46127 #undef TPACPI_MAY_SEND_KEY
46128 -}
46129
46130 /*
46131 * Polling driver
46132 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
46133 index e4ac38a..b13344c 100644
46134 --- a/drivers/platform/x86/wmi.c
46135 +++ b/drivers/platform/x86/wmi.c
46136 @@ -743,7 +743,7 @@ static int wmi_create_device(const struct guid_block *gblock,
46137 wblock->dev.class = &wmi_class;
46138
46139 wmi_gtoa(gblock->guid, guid_string);
46140 - dev_set_name(&wblock->dev, guid_string);
46141 + dev_set_name(&wblock->dev, "%s", guid_string);
46142
46143 dev_set_drvdata(&wblock->dev, wblock);
46144
46145 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
46146 index 769d265..a3a05ca 100644
46147 --- a/drivers/pnp/pnpbios/bioscalls.c
46148 +++ b/drivers/pnp/pnpbios/bioscalls.c
46149 @@ -58,7 +58,7 @@ do { \
46150 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
46151 } while(0)
46152
46153 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
46154 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
46155 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
46156
46157 /*
46158 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46159
46160 cpu = get_cpu();
46161 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
46162 +
46163 + pax_open_kernel();
46164 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
46165 + pax_close_kernel();
46166
46167 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
46168 spin_lock_irqsave(&pnp_bios_lock, flags);
46169 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46170 :"memory");
46171 spin_unlock_irqrestore(&pnp_bios_lock, flags);
46172
46173 + pax_open_kernel();
46174 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
46175 + pax_close_kernel();
46176 +
46177 put_cpu();
46178
46179 /* If we get here and this is set then the PnP BIOS faulted on us. */
46180 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
46181 return status;
46182 }
46183
46184 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
46185 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
46186 {
46187 int i;
46188
46189 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46190 pnp_bios_callpoint.offset = header->fields.pm16offset;
46191 pnp_bios_callpoint.segment = PNP_CS16;
46192
46193 + pax_open_kernel();
46194 +
46195 for_each_possible_cpu(i) {
46196 struct desc_struct *gdt = get_cpu_gdt_table(i);
46197 if (!gdt)
46198 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46199 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46200 (unsigned long)__va(header->fields.pm16dseg));
46201 }
46202 +
46203 + pax_close_kernel();
46204 }
46205 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46206 index 3e6db1c..1fbbdae 100644
46207 --- a/drivers/pnp/resource.c
46208 +++ b/drivers/pnp/resource.c
46209 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46210 return 1;
46211
46212 /* check if the resource is valid */
46213 - if (*irq < 0 || *irq > 15)
46214 + if (*irq > 15)
46215 return 0;
46216
46217 /* check if the resource is reserved */
46218 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46219 return 1;
46220
46221 /* check if the resource is valid */
46222 - if (*dma < 0 || *dma == 4 || *dma > 7)
46223 + if (*dma == 4 || *dma > 7)
46224 return 0;
46225
46226 /* check if the resource is reserved */
46227 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46228 index 0c52e2a..3421ab7 100644
46229 --- a/drivers/power/pda_power.c
46230 +++ b/drivers/power/pda_power.c
46231 @@ -37,7 +37,11 @@ static int polling;
46232
46233 #if IS_ENABLED(CONFIG_USB_PHY)
46234 static struct usb_phy *transceiver;
46235 -static struct notifier_block otg_nb;
46236 +static int otg_handle_notification(struct notifier_block *nb,
46237 + unsigned long event, void *unused);
46238 +static struct notifier_block otg_nb = {
46239 + .notifier_call = otg_handle_notification
46240 +};
46241 #endif
46242
46243 static struct regulator *ac_draw;
46244 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46245
46246 #if IS_ENABLED(CONFIG_USB_PHY)
46247 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46248 - otg_nb.notifier_call = otg_handle_notification;
46249 ret = usb_register_notifier(transceiver, &otg_nb);
46250 if (ret) {
46251 dev_err(dev, "failure to register otg notifier\n");
46252 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46253 index cc439fd..8fa30df 100644
46254 --- a/drivers/power/power_supply.h
46255 +++ b/drivers/power/power_supply.h
46256 @@ -16,12 +16,12 @@ struct power_supply;
46257
46258 #ifdef CONFIG_SYSFS
46259
46260 -extern void power_supply_init_attrs(struct device_type *dev_type);
46261 +extern void power_supply_init_attrs(void);
46262 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46263
46264 #else
46265
46266 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46267 +static inline void power_supply_init_attrs(void) {}
46268 #define power_supply_uevent NULL
46269
46270 #endif /* CONFIG_SYSFS */
46271 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46272 index 1c517c3..ffa2f17 100644
46273 --- a/drivers/power/power_supply_core.c
46274 +++ b/drivers/power/power_supply_core.c
46275 @@ -24,7 +24,10 @@
46276 struct class *power_supply_class;
46277 EXPORT_SYMBOL_GPL(power_supply_class);
46278
46279 -static struct device_type power_supply_dev_type;
46280 +extern const struct attribute_group *power_supply_attr_groups[];
46281 +static struct device_type power_supply_dev_type = {
46282 + .groups = power_supply_attr_groups,
46283 +};
46284
46285 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46286 struct power_supply *supply)
46287 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
46288 return PTR_ERR(power_supply_class);
46289
46290 power_supply_class->dev_uevent = power_supply_uevent;
46291 - power_supply_init_attrs(&power_supply_dev_type);
46292 + power_supply_init_attrs();
46293
46294 return 0;
46295 }
46296 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46297 index 29178f7..c65f324 100644
46298 --- a/drivers/power/power_supply_sysfs.c
46299 +++ b/drivers/power/power_supply_sysfs.c
46300 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46301 .is_visible = power_supply_attr_is_visible,
46302 };
46303
46304 -static const struct attribute_group *power_supply_attr_groups[] = {
46305 +const struct attribute_group *power_supply_attr_groups[] = {
46306 &power_supply_attr_group,
46307 NULL,
46308 };
46309
46310 -void power_supply_init_attrs(struct device_type *dev_type)
46311 +void power_supply_init_attrs(void)
46312 {
46313 int i;
46314
46315 - dev_type->groups = power_supply_attr_groups;
46316 -
46317 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46318 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46319 }
46320 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46321 index 815d6df..811633a 100644
46322 --- a/drivers/regulator/core.c
46323 +++ b/drivers/regulator/core.c
46324 @@ -3529,7 +3529,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46325 {
46326 const struct regulation_constraints *constraints = NULL;
46327 const struct regulator_init_data *init_data;
46328 - static atomic_t regulator_no = ATOMIC_INIT(0);
46329 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46330 struct regulator_dev *rdev;
46331 struct device *dev;
46332 int ret, i;
46333 @@ -3599,7 +3599,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46334 rdev->dev.of_node = config->of_node;
46335 rdev->dev.parent = dev;
46336 dev_set_name(&rdev->dev, "regulator.%d",
46337 - atomic_inc_return(&regulator_no) - 1);
46338 + atomic_inc_return_unchecked(&regulator_no) - 1);
46339 ret = device_register(&rdev->dev);
46340 if (ret != 0) {
46341 put_device(&rdev->dev);
46342 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46343 index d428ef9..fdc0357 100644
46344 --- a/drivers/regulator/max8660.c
46345 +++ b/drivers/regulator/max8660.c
46346 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
46347 max8660->shadow_regs[MAX8660_OVER1] = 5;
46348 } else {
46349 /* Otherwise devices can be toggled via software */
46350 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46351 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46352 + pax_open_kernel();
46353 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46354 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46355 + pax_close_kernel();
46356 }
46357
46358 /*
46359 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46360 index adb1414..c13e0ce 100644
46361 --- a/drivers/regulator/max8973-regulator.c
46362 +++ b/drivers/regulator/max8973-regulator.c
46363 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
46364 if (!pdata->enable_ext_control) {
46365 max->desc.enable_reg = MAX8973_VOUT;
46366 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46367 - max8973_dcdc_ops.enable = regulator_enable_regmap;
46368 - max8973_dcdc_ops.disable = regulator_disable_regmap;
46369 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
46370 + pax_open_kernel();
46371 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
46372 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
46373 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
46374 + pax_close_kernel();
46375 }
46376
46377 max->enable_external_control = pdata->enable_ext_control;
46378 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46379 index b716283..3cc4349 100644
46380 --- a/drivers/regulator/mc13892-regulator.c
46381 +++ b/drivers/regulator/mc13892-regulator.c
46382 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46383 }
46384 mc13xxx_unlock(mc13892);
46385
46386 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46387 + pax_open_kernel();
46388 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46389 = mc13892_vcam_set_mode;
46390 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46391 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46392 = mc13892_vcam_get_mode;
46393 + pax_close_kernel();
46394
46395 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46396 ARRAY_SIZE(mc13892_regulators));
46397 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46398 index f1cb706..4c7832a 100644
46399 --- a/drivers/rtc/rtc-cmos.c
46400 +++ b/drivers/rtc/rtc-cmos.c
46401 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46402 hpet_rtc_timer_init();
46403
46404 /* export at least the first block of NVRAM */
46405 - nvram.size = address_space - NVRAM_OFFSET;
46406 + pax_open_kernel();
46407 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46408 + pax_close_kernel();
46409 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46410 if (retval < 0) {
46411 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46412 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46413 index d049393..bb20be0 100644
46414 --- a/drivers/rtc/rtc-dev.c
46415 +++ b/drivers/rtc/rtc-dev.c
46416 @@ -16,6 +16,7 @@
46417 #include <linux/module.h>
46418 #include <linux/rtc.h>
46419 #include <linux/sched.h>
46420 +#include <linux/grsecurity.h>
46421 #include "rtc-core.h"
46422
46423 static dev_t rtc_devt;
46424 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46425 if (copy_from_user(&tm, uarg, sizeof(tm)))
46426 return -EFAULT;
46427
46428 + gr_log_timechange();
46429 +
46430 return rtc_set_time(rtc, &tm);
46431
46432 case RTC_PIE_ON:
46433 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46434 index b53992a..776df84 100644
46435 --- a/drivers/rtc/rtc-ds1307.c
46436 +++ b/drivers/rtc/rtc-ds1307.c
46437 @@ -107,7 +107,7 @@ struct ds1307 {
46438 u8 offset; /* register's offset */
46439 u8 regs[11];
46440 u16 nvram_offset;
46441 - struct bin_attribute *nvram;
46442 + bin_attribute_no_const *nvram;
46443 enum ds_type type;
46444 unsigned long flags;
46445 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46446 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46447 index 130f29a..6179d03 100644
46448 --- a/drivers/rtc/rtc-m48t59.c
46449 +++ b/drivers/rtc/rtc-m48t59.c
46450 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46451 goto out;
46452 }
46453
46454 - m48t59_nvram_attr.size = pdata->offset;
46455 + pax_open_kernel();
46456 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46457 + pax_close_kernel();
46458
46459 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46460 if (ret) {
46461 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46462 index e693af6..2e525b6 100644
46463 --- a/drivers/scsi/bfa/bfa_fcpim.h
46464 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46465 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46466
46467 struct bfa_itn_s {
46468 bfa_isr_func_t isr;
46469 -};
46470 +} __no_const;
46471
46472 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46473 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46474 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46475 index 23a90e7..9cf04ee 100644
46476 --- a/drivers/scsi/bfa/bfa_ioc.h
46477 +++ b/drivers/scsi/bfa/bfa_ioc.h
46478 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46479 bfa_ioc_disable_cbfn_t disable_cbfn;
46480 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46481 bfa_ioc_reset_cbfn_t reset_cbfn;
46482 -};
46483 +} __no_const;
46484
46485 /*
46486 * IOC event notification mechanism.
46487 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
46488 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
46489 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
46490 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
46491 -};
46492 +} __no_const;
46493
46494 /*
46495 * Queue element to wait for room in request queue. FIFO order is
46496 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46497 index 8c05ae01..b2cf224 100644
46498 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46499 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46500 @@ -33,8 +33,8 @@
46501 */
46502 #include "libfcoe.h"
46503
46504 -static atomic_t ctlr_num;
46505 -static atomic_t fcf_num;
46506 +static atomic_unchecked_t ctlr_num;
46507 +static atomic_unchecked_t fcf_num;
46508
46509 /*
46510 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46511 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46512 if (!ctlr)
46513 goto out;
46514
46515 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46516 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46517 ctlr->f = f;
46518 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46519 INIT_LIST_HEAD(&ctlr->fcfs);
46520 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46521 fcf->dev.parent = &ctlr->dev;
46522 fcf->dev.bus = &fcoe_bus_type;
46523 fcf->dev.type = &fcoe_fcf_device_type;
46524 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46525 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46526 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46527
46528 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46529 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46530 {
46531 int error;
46532
46533 - atomic_set(&ctlr_num, 0);
46534 - atomic_set(&fcf_num, 0);
46535 + atomic_set_unchecked(&ctlr_num, 0);
46536 + atomic_set_unchecked(&fcf_num, 0);
46537
46538 error = bus_register(&fcoe_bus_type);
46539 if (error)
46540 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46541 index df0c3c7..b00e1d0 100644
46542 --- a/drivers/scsi/hosts.c
46543 +++ b/drivers/scsi/hosts.c
46544 @@ -42,7 +42,7 @@
46545 #include "scsi_logging.h"
46546
46547
46548 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46549 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46550
46551
46552 static void scsi_host_cls_release(struct device *dev)
46553 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46554 * subtract one because we increment first then return, but we need to
46555 * know what the next host number was before increment
46556 */
46557 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46558 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46559 shost->dma_channel = 0xff;
46560
46561 /* These three are default values which can be overridden */
46562 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46563 index 7f4f790..b75b92a 100644
46564 --- a/drivers/scsi/hpsa.c
46565 +++ b/drivers/scsi/hpsa.c
46566 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46567 unsigned long flags;
46568
46569 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46570 - return h->access.command_completed(h, q);
46571 + return h->access->command_completed(h, q);
46572
46573 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46574 a = rq->head[rq->current_entry];
46575 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46576 while (!list_empty(&h->reqQ)) {
46577 c = list_entry(h->reqQ.next, struct CommandList, list);
46578 /* can't do anything if fifo is full */
46579 - if ((h->access.fifo_full(h))) {
46580 + if ((h->access->fifo_full(h))) {
46581 dev_warn(&h->pdev->dev, "fifo full\n");
46582 break;
46583 }
46584 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46585
46586 /* Tell the controller execute command */
46587 spin_unlock_irqrestore(&h->lock, flags);
46588 - h->access.submit_command(h, c);
46589 + h->access->submit_command(h, c);
46590 spin_lock_irqsave(&h->lock, flags);
46591 }
46592 spin_unlock_irqrestore(&h->lock, flags);
46593 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46594
46595 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46596 {
46597 - return h->access.command_completed(h, q);
46598 + return h->access->command_completed(h, q);
46599 }
46600
46601 static inline bool interrupt_pending(struct ctlr_info *h)
46602 {
46603 - return h->access.intr_pending(h);
46604 + return h->access->intr_pending(h);
46605 }
46606
46607 static inline long interrupt_not_for_us(struct ctlr_info *h)
46608 {
46609 - return (h->access.intr_pending(h) == 0) ||
46610 + return (h->access->intr_pending(h) == 0) ||
46611 (h->interrupts_enabled == 0);
46612 }
46613
46614 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46615 if (prod_index < 0)
46616 return -ENODEV;
46617 h->product_name = products[prod_index].product_name;
46618 - h->access = *(products[prod_index].access);
46619 + h->access = products[prod_index].access;
46620
46621 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46622 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46623 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46624
46625 assert_spin_locked(&lockup_detector_lock);
46626 remove_ctlr_from_lockup_detector_list(h);
46627 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46628 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46629 spin_lock_irqsave(&h->lock, flags);
46630 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46631 spin_unlock_irqrestore(&h->lock, flags);
46632 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46633 }
46634
46635 /* make sure the board interrupts are off */
46636 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46637 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46638
46639 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46640 goto clean2;
46641 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46642 * fake ones to scoop up any residual completions.
46643 */
46644 spin_lock_irqsave(&h->lock, flags);
46645 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46646 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46647 spin_unlock_irqrestore(&h->lock, flags);
46648 free_irqs(h);
46649 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46650 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46651 dev_info(&h->pdev->dev, "Board READY.\n");
46652 dev_info(&h->pdev->dev,
46653 "Waiting for stale completions to drain.\n");
46654 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46655 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46656 msleep(10000);
46657 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46658 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46659
46660 rc = controller_reset_failed(h->cfgtable);
46661 if (rc)
46662 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46663 }
46664
46665 /* Turn the interrupts on so we can service requests */
46666 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46667 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46668
46669 hpsa_hba_inquiry(h);
46670 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46671 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46672 * To write all data in the battery backed cache to disks
46673 */
46674 hpsa_flush_cache(h);
46675 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46676 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46677 hpsa_free_irqs_and_disable_msix(h);
46678 }
46679
46680 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46681 return;
46682 }
46683 /* Change the access methods to the performant access methods */
46684 - h->access = SA5_performant_access;
46685 + h->access = &SA5_performant_access;
46686 h->transMethod = CFGTBL_Trans_Performant;
46687 }
46688
46689 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46690 index 9816479..c5d4e97 100644
46691 --- a/drivers/scsi/hpsa.h
46692 +++ b/drivers/scsi/hpsa.h
46693 @@ -79,7 +79,7 @@ struct ctlr_info {
46694 unsigned int msix_vector;
46695 unsigned int msi_vector;
46696 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46697 - struct access_method access;
46698 + struct access_method *access;
46699
46700 /* queue and queue Info */
46701 struct list_head reqQ;
46702 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46703 index 8b928c6..9c76300 100644
46704 --- a/drivers/scsi/libfc/fc_exch.c
46705 +++ b/drivers/scsi/libfc/fc_exch.c
46706 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46707 u16 pool_max_index;
46708
46709 struct {
46710 - atomic_t no_free_exch;
46711 - atomic_t no_free_exch_xid;
46712 - atomic_t xid_not_found;
46713 - atomic_t xid_busy;
46714 - atomic_t seq_not_found;
46715 - atomic_t non_bls_resp;
46716 + atomic_unchecked_t no_free_exch;
46717 + atomic_unchecked_t no_free_exch_xid;
46718 + atomic_unchecked_t xid_not_found;
46719 + atomic_unchecked_t xid_busy;
46720 + atomic_unchecked_t seq_not_found;
46721 + atomic_unchecked_t non_bls_resp;
46722 } stats;
46723 };
46724
46725 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46726 /* allocate memory for exchange */
46727 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46728 if (!ep) {
46729 - atomic_inc(&mp->stats.no_free_exch);
46730 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46731 goto out;
46732 }
46733 memset(ep, 0, sizeof(*ep));
46734 @@ -797,7 +797,7 @@ out:
46735 return ep;
46736 err:
46737 spin_unlock_bh(&pool->lock);
46738 - atomic_inc(&mp->stats.no_free_exch_xid);
46739 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46740 mempool_free(ep, mp->ep_pool);
46741 return NULL;
46742 }
46743 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46744 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46745 ep = fc_exch_find(mp, xid);
46746 if (!ep) {
46747 - atomic_inc(&mp->stats.xid_not_found);
46748 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46749 reject = FC_RJT_OX_ID;
46750 goto out;
46751 }
46752 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46753 ep = fc_exch_find(mp, xid);
46754 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46755 if (ep) {
46756 - atomic_inc(&mp->stats.xid_busy);
46757 + atomic_inc_unchecked(&mp->stats.xid_busy);
46758 reject = FC_RJT_RX_ID;
46759 goto rel;
46760 }
46761 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46762 }
46763 xid = ep->xid; /* get our XID */
46764 } else if (!ep) {
46765 - atomic_inc(&mp->stats.xid_not_found);
46766 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46767 reject = FC_RJT_RX_ID; /* XID not found */
46768 goto out;
46769 }
46770 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46771 } else {
46772 sp = &ep->seq;
46773 if (sp->id != fh->fh_seq_id) {
46774 - atomic_inc(&mp->stats.seq_not_found);
46775 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46776 if (f_ctl & FC_FC_END_SEQ) {
46777 /*
46778 * Update sequence_id based on incoming last
46779 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46780
46781 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46782 if (!ep) {
46783 - atomic_inc(&mp->stats.xid_not_found);
46784 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46785 goto out;
46786 }
46787 if (ep->esb_stat & ESB_ST_COMPLETE) {
46788 - atomic_inc(&mp->stats.xid_not_found);
46789 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46790 goto rel;
46791 }
46792 if (ep->rxid == FC_XID_UNKNOWN)
46793 ep->rxid = ntohs(fh->fh_rx_id);
46794 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46795 - atomic_inc(&mp->stats.xid_not_found);
46796 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46797 goto rel;
46798 }
46799 if (ep->did != ntoh24(fh->fh_s_id) &&
46800 ep->did != FC_FID_FLOGI) {
46801 - atomic_inc(&mp->stats.xid_not_found);
46802 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46803 goto rel;
46804 }
46805 sof = fr_sof(fp);
46806 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46807 sp->ssb_stat |= SSB_ST_RESP;
46808 sp->id = fh->fh_seq_id;
46809 } else if (sp->id != fh->fh_seq_id) {
46810 - atomic_inc(&mp->stats.seq_not_found);
46811 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46812 goto rel;
46813 }
46814
46815 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46816 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46817
46818 if (!sp)
46819 - atomic_inc(&mp->stats.xid_not_found);
46820 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46821 else
46822 - atomic_inc(&mp->stats.non_bls_resp);
46823 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46824
46825 fc_frame_free(fp);
46826 }
46827 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46828
46829 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46830 mp = ema->mp;
46831 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46832 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46833 st->fc_no_free_exch_xid +=
46834 - atomic_read(&mp->stats.no_free_exch_xid);
46835 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46836 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46837 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46838 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46839 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46840 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46841 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46842 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46843 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46844 }
46845 }
46846 EXPORT_SYMBOL(fc_exch_update_stats);
46847 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46848 index 161c98e..6d563b3 100644
46849 --- a/drivers/scsi/libsas/sas_ata.c
46850 +++ b/drivers/scsi/libsas/sas_ata.c
46851 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46852 .postreset = ata_std_postreset,
46853 .error_handler = ata_std_error_handler,
46854 .post_internal_cmd = sas_ata_post_internal,
46855 - .qc_defer = ata_std_qc_defer,
46856 + .qc_defer = ata_std_qc_defer,
46857 .qc_prep = ata_noop_qc_prep,
46858 .qc_issue = sas_ata_qc_issue,
46859 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46860 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46861 index bcc56ca..6f4174a 100644
46862 --- a/drivers/scsi/lpfc/lpfc.h
46863 +++ b/drivers/scsi/lpfc/lpfc.h
46864 @@ -431,7 +431,7 @@ struct lpfc_vport {
46865 struct dentry *debug_nodelist;
46866 struct dentry *vport_debugfs_root;
46867 struct lpfc_debugfs_trc *disc_trc;
46868 - atomic_t disc_trc_cnt;
46869 + atomic_unchecked_t disc_trc_cnt;
46870 #endif
46871 uint8_t stat_data_enabled;
46872 uint8_t stat_data_blocked;
46873 @@ -865,8 +865,8 @@ struct lpfc_hba {
46874 struct timer_list fabric_block_timer;
46875 unsigned long bit_flags;
46876 #define FABRIC_COMANDS_BLOCKED 0
46877 - atomic_t num_rsrc_err;
46878 - atomic_t num_cmd_success;
46879 + atomic_unchecked_t num_rsrc_err;
46880 + atomic_unchecked_t num_cmd_success;
46881 unsigned long last_rsrc_error_time;
46882 unsigned long last_ramp_down_time;
46883 unsigned long last_ramp_up_time;
46884 @@ -902,7 +902,7 @@ struct lpfc_hba {
46885
46886 struct dentry *debug_slow_ring_trc;
46887 struct lpfc_debugfs_trc *slow_ring_trc;
46888 - atomic_t slow_ring_trc_cnt;
46889 + atomic_unchecked_t slow_ring_trc_cnt;
46890 /* iDiag debugfs sub-directory */
46891 struct dentry *idiag_root;
46892 struct dentry *idiag_pci_cfg;
46893 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46894 index f525ecb..32549a4 100644
46895 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46896 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46897 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46898
46899 #include <linux/debugfs.h>
46900
46901 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46902 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46903 static unsigned long lpfc_debugfs_start_time = 0L;
46904
46905 /* iDiag */
46906 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46907 lpfc_debugfs_enable = 0;
46908
46909 len = 0;
46910 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46911 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46912 (lpfc_debugfs_max_disc_trc - 1);
46913 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46914 dtp = vport->disc_trc + i;
46915 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46916 lpfc_debugfs_enable = 0;
46917
46918 len = 0;
46919 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46920 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46921 (lpfc_debugfs_max_slow_ring_trc - 1);
46922 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46923 dtp = phba->slow_ring_trc + i;
46924 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46925 !vport || !vport->disc_trc)
46926 return;
46927
46928 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46929 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46930 (lpfc_debugfs_max_disc_trc - 1);
46931 dtp = vport->disc_trc + index;
46932 dtp->fmt = fmt;
46933 dtp->data1 = data1;
46934 dtp->data2 = data2;
46935 dtp->data3 = data3;
46936 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46937 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46938 dtp->jif = jiffies;
46939 #endif
46940 return;
46941 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46942 !phba || !phba->slow_ring_trc)
46943 return;
46944
46945 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46946 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46947 (lpfc_debugfs_max_slow_ring_trc - 1);
46948 dtp = phba->slow_ring_trc + index;
46949 dtp->fmt = fmt;
46950 dtp->data1 = data1;
46951 dtp->data2 = data2;
46952 dtp->data3 = data3;
46953 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46954 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46955 dtp->jif = jiffies;
46956 #endif
46957 return;
46958 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46959 "slow_ring buffer\n");
46960 goto debug_failed;
46961 }
46962 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46963 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46964 memset(phba->slow_ring_trc, 0,
46965 (sizeof(struct lpfc_debugfs_trc) *
46966 lpfc_debugfs_max_slow_ring_trc));
46967 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46968 "buffer\n");
46969 goto debug_failed;
46970 }
46971 - atomic_set(&vport->disc_trc_cnt, 0);
46972 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46973
46974 snprintf(name, sizeof(name), "discovery_trace");
46975 vport->debug_disc_trc =
46976 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46977 index cb465b2..2e7b25f 100644
46978 --- a/drivers/scsi/lpfc/lpfc_init.c
46979 +++ b/drivers/scsi/lpfc/lpfc_init.c
46980 @@ -10950,8 +10950,10 @@ lpfc_init(void)
46981 "misc_register returned with status %d", error);
46982
46983 if (lpfc_enable_npiv) {
46984 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46985 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46986 + pax_open_kernel();
46987 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46988 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46989 + pax_close_kernel();
46990 }
46991 lpfc_transport_template =
46992 fc_attach_transport(&lpfc_transport_functions);
46993 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46994 index 8523b278e..ce1d812 100644
46995 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46996 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46997 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46998 uint32_t evt_posted;
46999
47000 spin_lock_irqsave(&phba->hbalock, flags);
47001 - atomic_inc(&phba->num_rsrc_err);
47002 + atomic_inc_unchecked(&phba->num_rsrc_err);
47003 phba->last_rsrc_error_time = jiffies;
47004
47005 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
47006 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
47007 unsigned long flags;
47008 struct lpfc_hba *phba = vport->phba;
47009 uint32_t evt_posted;
47010 - atomic_inc(&phba->num_cmd_success);
47011 + atomic_inc_unchecked(&phba->num_cmd_success);
47012
47013 if (vport->cfg_lun_queue_depth <= queue_depth)
47014 return;
47015 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
47016 unsigned long num_rsrc_err, num_cmd_success;
47017 int i;
47018
47019 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
47020 - num_cmd_success = atomic_read(&phba->num_cmd_success);
47021 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
47022 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
47023
47024 /*
47025 * The error and success command counters are global per
47026 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
47027 }
47028 }
47029 lpfc_destroy_vport_work_array(phba, vports);
47030 - atomic_set(&phba->num_rsrc_err, 0);
47031 - atomic_set(&phba->num_cmd_success, 0);
47032 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
47033 + atomic_set_unchecked(&phba->num_cmd_success, 0);
47034 }
47035
47036 /**
47037 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
47038 }
47039 }
47040 lpfc_destroy_vport_work_array(phba, vports);
47041 - atomic_set(&phba->num_rsrc_err, 0);
47042 - atomic_set(&phba->num_cmd_success, 0);
47043 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
47044 + atomic_set_unchecked(&phba->num_cmd_success, 0);
47045 }
47046
47047 /**
47048 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
47049 index 8e1b737..50ff510 100644
47050 --- a/drivers/scsi/pmcraid.c
47051 +++ b/drivers/scsi/pmcraid.c
47052 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
47053 res->scsi_dev = scsi_dev;
47054 scsi_dev->hostdata = res;
47055 res->change_detected = 0;
47056 - atomic_set(&res->read_failures, 0);
47057 - atomic_set(&res->write_failures, 0);
47058 + atomic_set_unchecked(&res->read_failures, 0);
47059 + atomic_set_unchecked(&res->write_failures, 0);
47060 rc = 0;
47061 }
47062 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
47063 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
47064
47065 /* If this was a SCSI read/write command keep count of errors */
47066 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
47067 - atomic_inc(&res->read_failures);
47068 + atomic_inc_unchecked(&res->read_failures);
47069 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
47070 - atomic_inc(&res->write_failures);
47071 + atomic_inc_unchecked(&res->write_failures);
47072
47073 if (!RES_IS_GSCSI(res->cfg_entry) &&
47074 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
47075 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
47076 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47077 * hrrq_id assigned here in queuecommand
47078 */
47079 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47080 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47081 pinstance->num_hrrq;
47082 cmd->cmd_done = pmcraid_io_done;
47083
47084 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
47085 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47086 * hrrq_id assigned here in queuecommand
47087 */
47088 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47089 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47090 pinstance->num_hrrq;
47091
47092 if (request_size) {
47093 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
47094
47095 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
47096 /* add resources only after host is added into system */
47097 - if (!atomic_read(&pinstance->expose_resources))
47098 + if (!atomic_read_unchecked(&pinstance->expose_resources))
47099 return;
47100
47101 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
47102 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
47103 init_waitqueue_head(&pinstance->reset_wait_q);
47104
47105 atomic_set(&pinstance->outstanding_cmds, 0);
47106 - atomic_set(&pinstance->last_message_id, 0);
47107 - atomic_set(&pinstance->expose_resources, 0);
47108 + atomic_set_unchecked(&pinstance->last_message_id, 0);
47109 + atomic_set_unchecked(&pinstance->expose_resources, 0);
47110
47111 INIT_LIST_HEAD(&pinstance->free_res_q);
47112 INIT_LIST_HEAD(&pinstance->used_res_q);
47113 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
47114 /* Schedule worker thread to handle CCN and take care of adding and
47115 * removing devices to OS
47116 */
47117 - atomic_set(&pinstance->expose_resources, 1);
47118 + atomic_set_unchecked(&pinstance->expose_resources, 1);
47119 schedule_work(&pinstance->worker_q);
47120 return rc;
47121
47122 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
47123 index e1d150f..6c6df44 100644
47124 --- a/drivers/scsi/pmcraid.h
47125 +++ b/drivers/scsi/pmcraid.h
47126 @@ -748,7 +748,7 @@ struct pmcraid_instance {
47127 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
47128
47129 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
47130 - atomic_t last_message_id;
47131 + atomic_unchecked_t last_message_id;
47132
47133 /* configuration table */
47134 struct pmcraid_config_table *cfg_table;
47135 @@ -777,7 +777,7 @@ struct pmcraid_instance {
47136 atomic_t outstanding_cmds;
47137
47138 /* should add/delete resources to mid-layer now ?*/
47139 - atomic_t expose_resources;
47140 + atomic_unchecked_t expose_resources;
47141
47142
47143
47144 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47145 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47146 };
47147 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47148 - atomic_t read_failures; /* count of failed READ commands */
47149 - atomic_t write_failures; /* count of failed WRITE commands */
47150 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47151 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47152
47153 /* To indicate add/delete/modify during CCN */
47154 u8 change_detected;
47155 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47156 index bf60c63..74d4dce 100644
47157 --- a/drivers/scsi/qla2xxx/qla_attr.c
47158 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47159 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47160 return 0;
47161 }
47162
47163 -struct fc_function_template qla2xxx_transport_functions = {
47164 +fc_function_template_no_const qla2xxx_transport_functions = {
47165
47166 .show_host_node_name = 1,
47167 .show_host_port_name = 1,
47168 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47169 .bsg_timeout = qla24xx_bsg_timeout,
47170 };
47171
47172 -struct fc_function_template qla2xxx_transport_vport_functions = {
47173 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47174
47175 .show_host_node_name = 1,
47176 .show_host_port_name = 1,
47177 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47178 index 026bfde..90c4018 100644
47179 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47180 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47181 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47182 struct device_attribute;
47183 extern struct device_attribute *qla2x00_host_attrs[];
47184 struct fc_function_template;
47185 -extern struct fc_function_template qla2xxx_transport_functions;
47186 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47187 +extern fc_function_template_no_const qla2xxx_transport_functions;
47188 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47189 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47190 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47191 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47192 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47193 index ad72c1d..afc9a98 100644
47194 --- a/drivers/scsi/qla2xxx/qla_os.c
47195 +++ b/drivers/scsi/qla2xxx/qla_os.c
47196 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47197 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47198 /* Ok, a 64bit DMA mask is applicable. */
47199 ha->flags.enable_64bit_addressing = 1;
47200 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47201 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47202 + pax_open_kernel();
47203 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47204 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47205 + pax_close_kernel();
47206 return;
47207 }
47208 }
47209 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47210 index ddf16a8..80f4dd0 100644
47211 --- a/drivers/scsi/qla4xxx/ql4_def.h
47212 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47213 @@ -291,7 +291,7 @@ struct ddb_entry {
47214 * (4000 only) */
47215 atomic_t relogin_timer; /* Max Time to wait for
47216 * relogin to complete */
47217 - atomic_t relogin_retry_count; /* Num of times relogin has been
47218 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47219 * retried */
47220 uint32_t default_time2wait; /* Default Min time between
47221 * relogins (+aens) */
47222 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47223 index 4d231c1..2892c37 100644
47224 --- a/drivers/scsi/qla4xxx/ql4_os.c
47225 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47226 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47227 */
47228 if (!iscsi_is_session_online(cls_sess)) {
47229 /* Reset retry relogin timer */
47230 - atomic_inc(&ddb_entry->relogin_retry_count);
47231 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47232 DEBUG2(ql4_printk(KERN_INFO, ha,
47233 "%s: index[%d] relogin timed out-retrying"
47234 " relogin (%d), retry (%d)\n", __func__,
47235 ddb_entry->fw_ddb_index,
47236 - atomic_read(&ddb_entry->relogin_retry_count),
47237 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47238 ddb_entry->default_time2wait + 4));
47239 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47240 atomic_set(&ddb_entry->retry_relogin_timer,
47241 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47242
47243 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47244 atomic_set(&ddb_entry->relogin_timer, 0);
47245 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47246 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47247 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47248 ddb_entry->default_relogin_timeout =
47249 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47250 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47251 index eaa808e..95f8841 100644
47252 --- a/drivers/scsi/scsi.c
47253 +++ b/drivers/scsi/scsi.c
47254 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47255 unsigned long timeout;
47256 int rtn = 0;
47257
47258 - atomic_inc(&cmd->device->iorequest_cnt);
47259 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47260
47261 /* check if the device is still usable */
47262 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47263 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47264 index 86d5220..f22c51a 100644
47265 --- a/drivers/scsi/scsi_lib.c
47266 +++ b/drivers/scsi/scsi_lib.c
47267 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47268 shost = sdev->host;
47269 scsi_init_cmd_errh(cmd);
47270 cmd->result = DID_NO_CONNECT << 16;
47271 - atomic_inc(&cmd->device->iorequest_cnt);
47272 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47273
47274 /*
47275 * SCSI request completion path will do scsi_device_unbusy(),
47276 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
47277
47278 INIT_LIST_HEAD(&cmd->eh_entry);
47279
47280 - atomic_inc(&cmd->device->iodone_cnt);
47281 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47282 if (cmd->result)
47283 - atomic_inc(&cmd->device->ioerr_cnt);
47284 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47285
47286 disposition = scsi_decide_disposition(cmd);
47287 if (disposition != SUCCESS &&
47288 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47289 index 931a7d9..0c2a754 100644
47290 --- a/drivers/scsi/scsi_sysfs.c
47291 +++ b/drivers/scsi/scsi_sysfs.c
47292 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47293 char *buf) \
47294 { \
47295 struct scsi_device *sdev = to_scsi_device(dev); \
47296 - unsigned long long count = atomic_read(&sdev->field); \
47297 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47298 return snprintf(buf, 20, "0x%llx\n", count); \
47299 } \
47300 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47301 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47302 index 84a1fdf..693b0d6 100644
47303 --- a/drivers/scsi/scsi_tgt_lib.c
47304 +++ b/drivers/scsi/scsi_tgt_lib.c
47305 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47306 int err;
47307
47308 dprintk("%lx %u\n", uaddr, len);
47309 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47310 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47311 if (err) {
47312 /*
47313 * TODO: need to fixup sg_tablesize, max_segment_size,
47314 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47315 index e106c27..11a380e 100644
47316 --- a/drivers/scsi/scsi_transport_fc.c
47317 +++ b/drivers/scsi/scsi_transport_fc.c
47318 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47319 * Netlink Infrastructure
47320 */
47321
47322 -static atomic_t fc_event_seq;
47323 +static atomic_unchecked_t fc_event_seq;
47324
47325 /**
47326 * fc_get_event_number - Obtain the next sequential FC event number
47327 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47328 u32
47329 fc_get_event_number(void)
47330 {
47331 - return atomic_add_return(1, &fc_event_seq);
47332 + return atomic_add_return_unchecked(1, &fc_event_seq);
47333 }
47334 EXPORT_SYMBOL(fc_get_event_number);
47335
47336 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47337 {
47338 int error;
47339
47340 - atomic_set(&fc_event_seq, 0);
47341 + atomic_set_unchecked(&fc_event_seq, 0);
47342
47343 error = transport_class_register(&fc_host_class);
47344 if (error)
47345 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47346 char *cp;
47347
47348 *val = simple_strtoul(buf, &cp, 0);
47349 - if ((*cp && (*cp != '\n')) || (*val < 0))
47350 + if (*cp && (*cp != '\n'))
47351 return -EINVAL;
47352 /*
47353 * Check for overflow; dev_loss_tmo is u32
47354 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47355 index 133926b..903000d 100644
47356 --- a/drivers/scsi/scsi_transport_iscsi.c
47357 +++ b/drivers/scsi/scsi_transport_iscsi.c
47358 @@ -80,7 +80,7 @@ struct iscsi_internal {
47359 struct transport_container session_cont;
47360 };
47361
47362 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47363 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47364 static struct workqueue_struct *iscsi_eh_timer_workq;
47365
47366 static DEFINE_IDA(iscsi_sess_ida);
47367 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47368 int err;
47369
47370 ihost = shost->shost_data;
47371 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47372 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47373
47374 if (target_id == ISCSI_MAX_TARGET) {
47375 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47376 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
47377 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47378 ISCSI_TRANSPORT_VERSION);
47379
47380 - atomic_set(&iscsi_session_nr, 0);
47381 + atomic_set_unchecked(&iscsi_session_nr, 0);
47382
47383 err = class_register(&iscsi_transport_class);
47384 if (err)
47385 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47386 index f379c7f..e8fc69c 100644
47387 --- a/drivers/scsi/scsi_transport_srp.c
47388 +++ b/drivers/scsi/scsi_transport_srp.c
47389 @@ -33,7 +33,7 @@
47390 #include "scsi_transport_srp_internal.h"
47391
47392 struct srp_host_attrs {
47393 - atomic_t next_port_id;
47394 + atomic_unchecked_t next_port_id;
47395 };
47396 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47397
47398 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47399 struct Scsi_Host *shost = dev_to_shost(dev);
47400 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47401
47402 - atomic_set(&srp_host->next_port_id, 0);
47403 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47404 return 0;
47405 }
47406
47407 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47408 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47409 rport->roles = ids->roles;
47410
47411 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47412 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47413 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47414
47415 transport_setup_device(&rport->dev);
47416 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47417 index 610417e..167c46c 100644
47418 --- a/drivers/scsi/sd.c
47419 +++ b/drivers/scsi/sd.c
47420 @@ -2928,7 +2928,7 @@ static int sd_probe(struct device *dev)
47421 sdkp->disk = gd;
47422 sdkp->index = index;
47423 atomic_set(&sdkp->openers, 0);
47424 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47425 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47426
47427 if (!sdp->request_queue->rq_timeout) {
47428 if (sdp->type != TYPE_MOD)
47429 @@ -2941,7 +2941,7 @@ static int sd_probe(struct device *dev)
47430 device_initialize(&sdkp->dev);
47431 sdkp->dev.parent = dev;
47432 sdkp->dev.class = &sd_disk_class;
47433 - dev_set_name(&sdkp->dev, dev_name(dev));
47434 + dev_set_name(&sdkp->dev, "%s", dev_name(dev));
47435
47436 if (device_add(&sdkp->dev))
47437 goto out_free_index;
47438 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47439 index df5e961..df6b97f 100644
47440 --- a/drivers/scsi/sg.c
47441 +++ b/drivers/scsi/sg.c
47442 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47443 sdp->disk->disk_name,
47444 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47445 NULL,
47446 - (char *)arg);
47447 + (char __user *)arg);
47448 case BLKTRACESTART:
47449 return blk_trace_startstop(sdp->device->request_queue, 1);
47450 case BLKTRACESTOP:
47451 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47452 index 32b7bb1..2f1c4bd 100644
47453 --- a/drivers/spi/spi.c
47454 +++ b/drivers/spi/spi.c
47455 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47456 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47457
47458 /* portable code must never pass more than 32 bytes */
47459 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47460 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47461
47462 static u8 *buf;
47463
47464 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47465 index ec9e2ae..cd15d67 100644
47466 --- a/drivers/staging/android/timed_output.c
47467 +++ b/drivers/staging/android/timed_output.c
47468 @@ -25,7 +25,7 @@
47469 #include "timed_output.h"
47470
47471 static struct class *timed_output_class;
47472 -static atomic_t device_count;
47473 +static atomic_unchecked_t device_count;
47474
47475 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47476 char *buf)
47477 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47478 timed_output_class = class_create(THIS_MODULE, "timed_output");
47479 if (IS_ERR(timed_output_class))
47480 return PTR_ERR(timed_output_class);
47481 - atomic_set(&device_count, 0);
47482 + atomic_set_unchecked(&device_count, 0);
47483 }
47484
47485 return 0;
47486 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47487 if (ret < 0)
47488 return ret;
47489
47490 - tdev->index = atomic_inc_return(&device_count);
47491 + tdev->index = atomic_inc_return_unchecked(&device_count);
47492 tdev->dev = device_create(timed_output_class, NULL,
47493 MKDEV(0, tdev->index), NULL, tdev->name);
47494 if (IS_ERR(tdev->dev))
47495 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47496 index 3675020..e80d92c 100644
47497 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47498 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47499 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47500
47501 static int solo_sysfs_init(struct solo_dev *solo_dev)
47502 {
47503 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47504 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47505 struct device *dev = &solo_dev->dev;
47506 const char *driver;
47507 int i;
47508 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47509 index 3335941..2b26186 100644
47510 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47511 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47512 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47513
47514 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47515 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47516 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47517 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47518 if (p2m_id < 0)
47519 p2m_id = -p2m_id;
47520 }
47521 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47522 index 6f91d2e..3f011d2 100644
47523 --- a/drivers/staging/media/solo6x10/solo6x10.h
47524 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47525 @@ -238,7 +238,7 @@ struct solo_dev {
47526
47527 /* P2M DMA Engine */
47528 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47529 - atomic_t p2m_count;
47530 + atomic_unchecked_t p2m_count;
47531 int p2m_jiffies;
47532 unsigned int p2m_timeouts;
47533
47534 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47535 index 34afc16..ffe44dd 100644
47536 --- a/drivers/staging/octeon/ethernet-rx.c
47537 +++ b/drivers/staging/octeon/ethernet-rx.c
47538 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47539 /* Increment RX stats for virtual ports */
47540 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47541 #ifdef CONFIG_64BIT
47542 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47543 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47544 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47545 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47546 #else
47547 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47548 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47549 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47550 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47551 #endif
47552 }
47553 netif_receive_skb(skb);
47554 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47555 dev->name);
47556 */
47557 #ifdef CONFIG_64BIT
47558 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47559 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47560 #else
47561 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47562 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47563 #endif
47564 dev_kfree_skb_irq(skb);
47565 }
47566 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47567 index c3a90e7..023619a 100644
47568 --- a/drivers/staging/octeon/ethernet.c
47569 +++ b/drivers/staging/octeon/ethernet.c
47570 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47571 * since the RX tasklet also increments it.
47572 */
47573 #ifdef CONFIG_64BIT
47574 - atomic64_add(rx_status.dropped_packets,
47575 - (atomic64_t *)&priv->stats.rx_dropped);
47576 + atomic64_add_unchecked(rx_status.dropped_packets,
47577 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47578 #else
47579 - atomic_add(rx_status.dropped_packets,
47580 - (atomic_t *)&priv->stats.rx_dropped);
47581 + atomic_add_unchecked(rx_status.dropped_packets,
47582 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47583 #endif
47584 }
47585
47586 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47587 index dc23395..cf7e9b1 100644
47588 --- a/drivers/staging/rtl8712/rtl871x_io.h
47589 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47590 @@ -108,7 +108,7 @@ struct _io_ops {
47591 u8 *pmem);
47592 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47593 u8 *pmem);
47594 -};
47595 +} __no_const;
47596
47597 struct io_req {
47598 struct list_head list;
47599 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47600 index 1f5088b..0e59820 100644
47601 --- a/drivers/staging/sbe-2t3e3/netdev.c
47602 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47603 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47604 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47605
47606 if (rlen)
47607 - if (copy_to_user(data, &resp, rlen))
47608 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47609 return -EFAULT;
47610
47611 return 0;
47612 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47613 index a863a98..d272795 100644
47614 --- a/drivers/staging/usbip/vhci.h
47615 +++ b/drivers/staging/usbip/vhci.h
47616 @@ -83,7 +83,7 @@ struct vhci_hcd {
47617 unsigned resuming:1;
47618 unsigned long re_timeout;
47619
47620 - atomic_t seqnum;
47621 + atomic_unchecked_t seqnum;
47622
47623 /*
47624 * NOTE:
47625 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47626 index d7974cb..d78076b 100644
47627 --- a/drivers/staging/usbip/vhci_hcd.c
47628 +++ b/drivers/staging/usbip/vhci_hcd.c
47629 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47630
47631 spin_lock(&vdev->priv_lock);
47632
47633 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47634 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47635 if (priv->seqnum == 0xffff)
47636 dev_info(&urb->dev->dev, "seqnum max\n");
47637
47638 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47639 return -ENOMEM;
47640 }
47641
47642 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47643 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47644 if (unlink->seqnum == 0xffff)
47645 pr_info("seqnum max\n");
47646
47647 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47648 vdev->rhport = rhport;
47649 }
47650
47651 - atomic_set(&vhci->seqnum, 0);
47652 + atomic_set_unchecked(&vhci->seqnum, 0);
47653 spin_lock_init(&vhci->lock);
47654
47655 hcd->power_budget = 0; /* no limit */
47656 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47657 index d07fcb5..358e1e1 100644
47658 --- a/drivers/staging/usbip/vhci_rx.c
47659 +++ b/drivers/staging/usbip/vhci_rx.c
47660 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47661 if (!urb) {
47662 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47663 pr_info("max seqnum %d\n",
47664 - atomic_read(&the_controller->seqnum));
47665 + atomic_read_unchecked(&the_controller->seqnum));
47666 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47667 return;
47668 }
47669 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47670 index 8417c2f..ef5ebd6 100644
47671 --- a/drivers/staging/vt6655/hostap.c
47672 +++ b/drivers/staging/vt6655/hostap.c
47673 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47674 *
47675 */
47676
47677 +static net_device_ops_no_const apdev_netdev_ops;
47678 +
47679 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47680 {
47681 PSDevice apdev_priv;
47682 struct net_device *dev = pDevice->dev;
47683 int ret;
47684 - const struct net_device_ops apdev_netdev_ops = {
47685 - .ndo_start_xmit = pDevice->tx_80211,
47686 - };
47687
47688 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47689
47690 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47691 *apdev_priv = *pDevice;
47692 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47693
47694 + /* only half broken now */
47695 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47696 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47697
47698 pDevice->apdev->type = ARPHRD_IEEE80211;
47699 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47700 index c699a30..b90a5fd 100644
47701 --- a/drivers/staging/vt6656/hostap.c
47702 +++ b/drivers/staging/vt6656/hostap.c
47703 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47704 *
47705 */
47706
47707 +static net_device_ops_no_const apdev_netdev_ops;
47708 +
47709 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47710 {
47711 struct vnt_private *apdev_priv;
47712 struct net_device *dev = pDevice->dev;
47713 int ret;
47714 - const struct net_device_ops apdev_netdev_ops = {
47715 - .ndo_start_xmit = pDevice->tx_80211,
47716 - };
47717
47718 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47719
47720 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47721 *apdev_priv = *pDevice;
47722 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47723
47724 + /* only half broken now */
47725 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47726 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47727
47728 pDevice->apdev->type = ARPHRD_IEEE80211;
47729 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47730 index d128ce2..fc1f9a1 100644
47731 --- a/drivers/staging/zcache/tmem.h
47732 +++ b/drivers/staging/zcache/tmem.h
47733 @@ -225,7 +225,7 @@ struct tmem_pamops {
47734 bool (*is_remote)(void *);
47735 int (*replace_in_obj)(void *, struct tmem_obj *);
47736 #endif
47737 -};
47738 +} __no_const;
47739 extern void tmem_register_pamops(struct tmem_pamops *m);
47740
47741 /* memory allocation methods provided by the host implementation */
47742 @@ -234,7 +234,7 @@ struct tmem_hostops {
47743 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47744 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47745 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47746 -};
47747 +} __no_const;
47748 extern void tmem_register_hostops(struct tmem_hostops *m);
47749
47750 /* core tmem accessor functions */
47751 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47752 index d3536f5..a0c2ce9 100644
47753 --- a/drivers/target/sbp/sbp_target.c
47754 +++ b/drivers/target/sbp/sbp_target.c
47755 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47756
47757 #define SESSION_MAINTENANCE_INTERVAL HZ
47758
47759 -static atomic_t login_id = ATOMIC_INIT(0);
47760 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47761
47762 static void session_maintenance_work(struct work_struct *);
47763 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47764 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47765 login->lun = se_lun;
47766 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47767 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47768 - login->login_id = atomic_inc_return(&login_id);
47769 + login->login_id = atomic_inc_return_unchecked(&login_id);
47770
47771 login->tgt_agt = sbp_target_agent_register(login);
47772 if (IS_ERR(login->tgt_agt)) {
47773 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47774 index 4630481..c26782a 100644
47775 --- a/drivers/target/target_core_device.c
47776 +++ b/drivers/target/target_core_device.c
47777 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47778 spin_lock_init(&dev->se_port_lock);
47779 spin_lock_init(&dev->se_tmr_lock);
47780 spin_lock_init(&dev->qf_cmd_lock);
47781 - atomic_set(&dev->dev_ordered_id, 0);
47782 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47783 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47784 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47785 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47786 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47787 index 21e3158..43c6004 100644
47788 --- a/drivers/target/target_core_transport.c
47789 +++ b/drivers/target/target_core_transport.c
47790 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47791 * Used to determine when ORDERED commands should go from
47792 * Dormant to Active status.
47793 */
47794 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47795 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47796 smp_mb__after_atomic_inc();
47797 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47798 cmd->se_ordered_id, cmd->sam_task_attr,
47799 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47800 index 33f83fe..d80f8e1 100644
47801 --- a/drivers/tty/cyclades.c
47802 +++ b/drivers/tty/cyclades.c
47803 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47804 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47805 info->port.count);
47806 #endif
47807 - info->port.count++;
47808 + atomic_inc(&info->port.count);
47809 #ifdef CY_DEBUG_COUNT
47810 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47811 - current->pid, info->port.count);
47812 + current->pid, atomic_read(&info->port.count));
47813 #endif
47814
47815 /*
47816 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47817 for (j = 0; j < cy_card[i].nports; j++) {
47818 info = &cy_card[i].ports[j];
47819
47820 - if (info->port.count) {
47821 + if (atomic_read(&info->port.count)) {
47822 /* XXX is the ldisc num worth this? */
47823 struct tty_struct *tty;
47824 struct tty_ldisc *ld;
47825 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47826 index eb255e8..f637a57 100644
47827 --- a/drivers/tty/hvc/hvc_console.c
47828 +++ b/drivers/tty/hvc/hvc_console.c
47829 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47830
47831 spin_lock_irqsave(&hp->port.lock, flags);
47832 /* Check and then increment for fast path open. */
47833 - if (hp->port.count++ > 0) {
47834 + if (atomic_inc_return(&hp->port.count) > 1) {
47835 spin_unlock_irqrestore(&hp->port.lock, flags);
47836 hvc_kick();
47837 return 0;
47838 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47839
47840 spin_lock_irqsave(&hp->port.lock, flags);
47841
47842 - if (--hp->port.count == 0) {
47843 + if (atomic_dec_return(&hp->port.count) == 0) {
47844 spin_unlock_irqrestore(&hp->port.lock, flags);
47845 /* We are done with the tty pointer now. */
47846 tty_port_tty_set(&hp->port, NULL);
47847 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47848 */
47849 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47850 } else {
47851 - if (hp->port.count < 0)
47852 + if (atomic_read(&hp->port.count) < 0)
47853 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47854 - hp->vtermno, hp->port.count);
47855 + hp->vtermno, atomic_read(&hp->port.count));
47856 spin_unlock_irqrestore(&hp->port.lock, flags);
47857 }
47858 }
47859 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47860 * open->hangup case this can be called after the final close so prevent
47861 * that from happening for now.
47862 */
47863 - if (hp->port.count <= 0) {
47864 + if (atomic_read(&hp->port.count) <= 0) {
47865 spin_unlock_irqrestore(&hp->port.lock, flags);
47866 return;
47867 }
47868
47869 - hp->port.count = 0;
47870 + atomic_set(&hp->port.count, 0);
47871 spin_unlock_irqrestore(&hp->port.lock, flags);
47872 tty_port_tty_set(&hp->port, NULL);
47873
47874 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47875 return -EPIPE;
47876
47877 /* FIXME what's this (unprotected) check for? */
47878 - if (hp->port.count <= 0)
47879 + if (atomic_read(&hp->port.count) <= 0)
47880 return -EIO;
47881
47882 spin_lock_irqsave(&hp->lock, flags);
47883 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47884 index 81e939e..95ead10 100644
47885 --- a/drivers/tty/hvc/hvcs.c
47886 +++ b/drivers/tty/hvc/hvcs.c
47887 @@ -83,6 +83,7 @@
47888 #include <asm/hvcserver.h>
47889 #include <asm/uaccess.h>
47890 #include <asm/vio.h>
47891 +#include <asm/local.h>
47892
47893 /*
47894 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47895 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47896
47897 spin_lock_irqsave(&hvcsd->lock, flags);
47898
47899 - if (hvcsd->port.count > 0) {
47900 + if (atomic_read(&hvcsd->port.count) > 0) {
47901 spin_unlock_irqrestore(&hvcsd->lock, flags);
47902 printk(KERN_INFO "HVCS: vterm state unchanged. "
47903 "The hvcs device node is still in use.\n");
47904 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47905 }
47906 }
47907
47908 - hvcsd->port.count = 0;
47909 + atomic_set(&hvcsd->port.count, 0);
47910 hvcsd->port.tty = tty;
47911 tty->driver_data = hvcsd;
47912
47913 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47914 unsigned long flags;
47915
47916 spin_lock_irqsave(&hvcsd->lock, flags);
47917 - hvcsd->port.count++;
47918 + atomic_inc(&hvcsd->port.count);
47919 hvcsd->todo_mask |= HVCS_SCHED_READ;
47920 spin_unlock_irqrestore(&hvcsd->lock, flags);
47921
47922 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47923 hvcsd = tty->driver_data;
47924
47925 spin_lock_irqsave(&hvcsd->lock, flags);
47926 - if (--hvcsd->port.count == 0) {
47927 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47928
47929 vio_disable_interrupts(hvcsd->vdev);
47930
47931 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47932
47933 free_irq(irq, hvcsd);
47934 return;
47935 - } else if (hvcsd->port.count < 0) {
47936 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47937 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47938 " is missmanaged.\n",
47939 - hvcsd->vdev->unit_address, hvcsd->port.count);
47940 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47941 }
47942
47943 spin_unlock_irqrestore(&hvcsd->lock, flags);
47944 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47945
47946 spin_lock_irqsave(&hvcsd->lock, flags);
47947 /* Preserve this so that we know how many kref refs to put */
47948 - temp_open_count = hvcsd->port.count;
47949 + temp_open_count = atomic_read(&hvcsd->port.count);
47950
47951 /*
47952 * Don't kref put inside the spinlock because the destruction
47953 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47954 tty->driver_data = NULL;
47955 hvcsd->port.tty = NULL;
47956
47957 - hvcsd->port.count = 0;
47958 + atomic_set(&hvcsd->port.count, 0);
47959
47960 /* This will drop any buffered data on the floor which is OK in a hangup
47961 * scenario. */
47962 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47963 * the middle of a write operation? This is a crummy place to do this
47964 * but we want to keep it all in the spinlock.
47965 */
47966 - if (hvcsd->port.count <= 0) {
47967 + if (atomic_read(&hvcsd->port.count) <= 0) {
47968 spin_unlock_irqrestore(&hvcsd->lock, flags);
47969 return -ENODEV;
47970 }
47971 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47972 {
47973 struct hvcs_struct *hvcsd = tty->driver_data;
47974
47975 - if (!hvcsd || hvcsd->port.count <= 0)
47976 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47977 return 0;
47978
47979 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47980 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47981 index 4190199..48f2920 100644
47982 --- a/drivers/tty/hvc/hvsi.c
47983 +++ b/drivers/tty/hvc/hvsi.c
47984 @@ -85,7 +85,7 @@ struct hvsi_struct {
47985 int n_outbuf;
47986 uint32_t vtermno;
47987 uint32_t virq;
47988 - atomic_t seqno; /* HVSI packet sequence number */
47989 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47990 uint16_t mctrl;
47991 uint8_t state; /* HVSI protocol state */
47992 uint8_t flags;
47993 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47994
47995 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47996 packet.hdr.len = sizeof(struct hvsi_query_response);
47997 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47998 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47999 packet.verb = VSV_SEND_VERSION_NUMBER;
48000 packet.u.version = HVSI_VERSION;
48001 packet.query_seqno = query_seqno+1;
48002 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
48003
48004 packet.hdr.type = VS_QUERY_PACKET_HEADER;
48005 packet.hdr.len = sizeof(struct hvsi_query);
48006 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48007 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48008 packet.verb = verb;
48009
48010 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
48011 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
48012 int wrote;
48013
48014 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
48015 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48016 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48017 packet.hdr.len = sizeof(struct hvsi_control);
48018 packet.verb = VSV_SET_MODEM_CTL;
48019 packet.mask = HVSI_TSDTR;
48020 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
48021 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
48022
48023 packet.hdr.type = VS_DATA_PACKET_HEADER;
48024 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48025 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48026 packet.hdr.len = count + sizeof(struct hvsi_header);
48027 memcpy(&packet.data, buf, count);
48028
48029 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
48030 struct hvsi_control packet __ALIGNED__;
48031
48032 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
48033 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48034 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48035 packet.hdr.len = 6;
48036 packet.verb = VSV_CLOSE_PROTOCOL;
48037
48038 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
48039 index 3396eb9..6d3d540 100644
48040 --- a/drivers/tty/hvc/hvsi_lib.c
48041 +++ b/drivers/tty/hvc/hvsi_lib.c
48042 @@ -9,7 +9,7 @@
48043
48044 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
48045 {
48046 - packet->seqno = atomic_inc_return(&pv->seqno);
48047 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
48048
48049 /* Assumes that always succeeds, works in practice */
48050 return pv->put_chars(pv->termno, (char *)packet, packet->len);
48051 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
48052
48053 /* Reset state */
48054 pv->established = 0;
48055 - atomic_set(&pv->seqno, 0);
48056 + atomic_set_unchecked(&pv->seqno, 0);
48057
48058 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
48059
48060 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
48061 pv->mctrl_update = 0;
48062 q.hdr.type = VS_QUERY_PACKET_HEADER;
48063 q.hdr.len = sizeof(struct hvsi_query);
48064 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
48065 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
48066 q.verb = VSV_SEND_MODEM_CTL_STATUS;
48067 rc = hvsi_send_packet(pv, &q.hdr);
48068 if (rc <= 0) {
48069 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
48070 index 8fd72ff..34a0bed 100644
48071 --- a/drivers/tty/ipwireless/tty.c
48072 +++ b/drivers/tty/ipwireless/tty.c
48073 @@ -29,6 +29,7 @@
48074 #include <linux/tty_driver.h>
48075 #include <linux/tty_flip.h>
48076 #include <linux/uaccess.h>
48077 +#include <asm/local.h>
48078
48079 #include "tty.h"
48080 #include "network.h"
48081 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48082 mutex_unlock(&tty->ipw_tty_mutex);
48083 return -ENODEV;
48084 }
48085 - if (tty->port.count == 0)
48086 + if (atomic_read(&tty->port.count) == 0)
48087 tty->tx_bytes_queued = 0;
48088
48089 - tty->port.count++;
48090 + atomic_inc(&tty->port.count);
48091
48092 tty->port.tty = linux_tty;
48093 linux_tty->driver_data = tty;
48094 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48095
48096 static void do_ipw_close(struct ipw_tty *tty)
48097 {
48098 - tty->port.count--;
48099 -
48100 - if (tty->port.count == 0) {
48101 + if (atomic_dec_return(&tty->port.count) == 0) {
48102 struct tty_struct *linux_tty = tty->port.tty;
48103
48104 if (linux_tty != NULL) {
48105 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
48106 return;
48107
48108 mutex_lock(&tty->ipw_tty_mutex);
48109 - if (tty->port.count == 0) {
48110 + if (atomic_read(&tty->port.count) == 0) {
48111 mutex_unlock(&tty->ipw_tty_mutex);
48112 return;
48113 }
48114 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
48115
48116 mutex_lock(&tty->ipw_tty_mutex);
48117
48118 - if (!tty->port.count) {
48119 + if (!atomic_read(&tty->port.count)) {
48120 mutex_unlock(&tty->ipw_tty_mutex);
48121 return;
48122 }
48123 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
48124 return -ENODEV;
48125
48126 mutex_lock(&tty->ipw_tty_mutex);
48127 - if (!tty->port.count) {
48128 + if (!atomic_read(&tty->port.count)) {
48129 mutex_unlock(&tty->ipw_tty_mutex);
48130 return -EINVAL;
48131 }
48132 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
48133 if (!tty)
48134 return -ENODEV;
48135
48136 - if (!tty->port.count)
48137 + if (!atomic_read(&tty->port.count))
48138 return -EINVAL;
48139
48140 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
48141 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
48142 if (!tty)
48143 return 0;
48144
48145 - if (!tty->port.count)
48146 + if (!atomic_read(&tty->port.count))
48147 return 0;
48148
48149 return tty->tx_bytes_queued;
48150 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48151 if (!tty)
48152 return -ENODEV;
48153
48154 - if (!tty->port.count)
48155 + if (!atomic_read(&tty->port.count))
48156 return -EINVAL;
48157
48158 return get_control_lines(tty);
48159 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48160 if (!tty)
48161 return -ENODEV;
48162
48163 - if (!tty->port.count)
48164 + if (!atomic_read(&tty->port.count))
48165 return -EINVAL;
48166
48167 return set_control_lines(tty, set, clear);
48168 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48169 if (!tty)
48170 return -ENODEV;
48171
48172 - if (!tty->port.count)
48173 + if (!atomic_read(&tty->port.count))
48174 return -EINVAL;
48175
48176 /* FIXME: Exactly how is the tty object locked here .. */
48177 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48178 * are gone */
48179 mutex_lock(&ttyj->ipw_tty_mutex);
48180 }
48181 - while (ttyj->port.count)
48182 + while (atomic_read(&ttyj->port.count))
48183 do_ipw_close(ttyj);
48184 ipwireless_disassociate_network_ttys(network,
48185 ttyj->channel_idx);
48186 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48187 index 1deaca4..c8582d4 100644
48188 --- a/drivers/tty/moxa.c
48189 +++ b/drivers/tty/moxa.c
48190 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48191 }
48192
48193 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48194 - ch->port.count++;
48195 + atomic_inc(&ch->port.count);
48196 tty->driver_data = ch;
48197 tty_port_tty_set(&ch->port, tty);
48198 mutex_lock(&ch->port.mutex);
48199 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48200 index 6422390..49003ac8 100644
48201 --- a/drivers/tty/n_gsm.c
48202 +++ b/drivers/tty/n_gsm.c
48203 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48204 spin_lock_init(&dlci->lock);
48205 mutex_init(&dlci->mutex);
48206 dlci->fifo = &dlci->_fifo;
48207 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48208 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48209 kfree(dlci);
48210 return NULL;
48211 }
48212 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48213 struct gsm_dlci *dlci = tty->driver_data;
48214 struct tty_port *port = &dlci->port;
48215
48216 - port->count++;
48217 + atomic_inc(&port->count);
48218 dlci_get(dlci);
48219 dlci_get(dlci->gsm->dlci[0]);
48220 mux_get(dlci->gsm);
48221 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48222 index 6c7fe90..9241dab 100644
48223 --- a/drivers/tty/n_tty.c
48224 +++ b/drivers/tty/n_tty.c
48225 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48226 {
48227 *ops = tty_ldisc_N_TTY;
48228 ops->owner = NULL;
48229 - ops->refcount = ops->flags = 0;
48230 + atomic_set(&ops->refcount, 0);
48231 + ops->flags = 0;
48232 }
48233 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48234 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48235 index abfd990..5ab5da9 100644
48236 --- a/drivers/tty/pty.c
48237 +++ b/drivers/tty/pty.c
48238 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
48239 panic("Couldn't register Unix98 pts driver");
48240
48241 /* Now create the /dev/ptmx special device */
48242 + pax_open_kernel();
48243 tty_default_fops(&ptmx_fops);
48244 - ptmx_fops.open = ptmx_open;
48245 + *(void **)&ptmx_fops.open = ptmx_open;
48246 + pax_close_kernel();
48247
48248 cdev_init(&ptmx_cdev, &ptmx_fops);
48249 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48250 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48251 index 354564e..fe50d9a 100644
48252 --- a/drivers/tty/rocket.c
48253 +++ b/drivers/tty/rocket.c
48254 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48255 tty->driver_data = info;
48256 tty_port_tty_set(port, tty);
48257
48258 - if (port->count++ == 0) {
48259 + if (atomic_inc_return(&port->count) == 1) {
48260 atomic_inc(&rp_num_ports_open);
48261
48262 #ifdef ROCKET_DEBUG_OPEN
48263 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48264 #endif
48265 }
48266 #ifdef ROCKET_DEBUG_OPEN
48267 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48268 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48269 #endif
48270
48271 /*
48272 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48273 spin_unlock_irqrestore(&info->port.lock, flags);
48274 return;
48275 }
48276 - if (info->port.count)
48277 + if (atomic_read(&info->port.count))
48278 atomic_dec(&rp_num_ports_open);
48279 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48280 spin_unlock_irqrestore(&info->port.lock, flags);
48281 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48282 index e2520ab..034e20b 100644
48283 --- a/drivers/tty/serial/ioc4_serial.c
48284 +++ b/drivers/tty/serial/ioc4_serial.c
48285 @@ -437,7 +437,7 @@ struct ioc4_soft {
48286 } is_intr_info[MAX_IOC4_INTR_ENTS];
48287
48288 /* Number of entries active in the above array */
48289 - atomic_t is_num_intrs;
48290 + atomic_unchecked_t is_num_intrs;
48291 } is_intr_type[IOC4_NUM_INTR_TYPES];
48292
48293 /* is_ir_lock must be held while
48294 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48295 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48296 || (type == IOC4_OTHER_INTR_TYPE)));
48297
48298 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48299 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48300 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48301
48302 /* Save off the lower level interrupt handler */
48303 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48304
48305 soft = arg;
48306 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48307 - num_intrs = (int)atomic_read(
48308 + num_intrs = (int)atomic_read_unchecked(
48309 &soft->is_intr_type[intr_type].is_num_intrs);
48310
48311 this_mir = this_ir = pending_intrs(soft, intr_type);
48312 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48313 index 1002054..dd644a8 100644
48314 --- a/drivers/tty/serial/kgdboc.c
48315 +++ b/drivers/tty/serial/kgdboc.c
48316 @@ -24,8 +24,9 @@
48317 #define MAX_CONFIG_LEN 40
48318
48319 static struct kgdb_io kgdboc_io_ops;
48320 +static struct kgdb_io kgdboc_io_ops_console;
48321
48322 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48323 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48324 static int configured = -1;
48325
48326 static char config[MAX_CONFIG_LEN];
48327 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48328 kgdboc_unregister_kbd();
48329 if (configured == 1)
48330 kgdb_unregister_io_module(&kgdboc_io_ops);
48331 + else if (configured == 2)
48332 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48333 }
48334
48335 static int configure_kgdboc(void)
48336 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48337 int err;
48338 char *cptr = config;
48339 struct console *cons;
48340 + int is_console = 0;
48341
48342 err = kgdboc_option_setup(config);
48343 if (err || !strlen(config) || isspace(config[0]))
48344 goto noconfig;
48345
48346 err = -ENODEV;
48347 - kgdboc_io_ops.is_console = 0;
48348 kgdb_tty_driver = NULL;
48349
48350 kgdboc_use_kms = 0;
48351 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48352 int idx;
48353 if (cons->device && cons->device(cons, &idx) == p &&
48354 idx == tty_line) {
48355 - kgdboc_io_ops.is_console = 1;
48356 + is_console = 1;
48357 break;
48358 }
48359 cons = cons->next;
48360 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48361 kgdb_tty_line = tty_line;
48362
48363 do_register:
48364 - err = kgdb_register_io_module(&kgdboc_io_ops);
48365 + if (is_console) {
48366 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48367 + configured = 2;
48368 + } else {
48369 + err = kgdb_register_io_module(&kgdboc_io_ops);
48370 + configured = 1;
48371 + }
48372 if (err)
48373 goto noconfig;
48374
48375 @@ -205,8 +214,6 @@ do_register:
48376 if (err)
48377 goto nmi_con_failed;
48378
48379 - configured = 1;
48380 -
48381 return 0;
48382
48383 nmi_con_failed:
48384 @@ -223,7 +230,7 @@ noconfig:
48385 static int __init init_kgdboc(void)
48386 {
48387 /* Already configured? */
48388 - if (configured == 1)
48389 + if (configured >= 1)
48390 return 0;
48391
48392 return configure_kgdboc();
48393 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48394 if (config[len - 1] == '\n')
48395 config[len - 1] = '\0';
48396
48397 - if (configured == 1)
48398 + if (configured >= 1)
48399 cleanup_kgdboc();
48400
48401 /* Go and configure with the new params. */
48402 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48403 .post_exception = kgdboc_post_exp_handler,
48404 };
48405
48406 +static struct kgdb_io kgdboc_io_ops_console = {
48407 + .name = "kgdboc",
48408 + .read_char = kgdboc_get_char,
48409 + .write_char = kgdboc_put_char,
48410 + .pre_exception = kgdboc_pre_exp_handler,
48411 + .post_exception = kgdboc_post_exp_handler,
48412 + .is_console = 1
48413 +};
48414 +
48415 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48416 /* This is only available if kgdboc is a built in for early debugging */
48417 static int __init kgdboc_early_init(char *opt)
48418 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48419 index b11e997..6d25a3b 100644
48420 --- a/drivers/tty/serial/msm_serial.c
48421 +++ b/drivers/tty/serial/msm_serial.c
48422 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48423 .cons = MSM_CONSOLE,
48424 };
48425
48426 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48427 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48428
48429 static int __init msm_serial_probe(struct platform_device *pdev)
48430 {
48431 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48432 int irq;
48433
48434 if (pdev->id == -1)
48435 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48436 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48437
48438 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48439 return -ENXIO;
48440 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48441 index 0c8a9fa..234a95f 100644
48442 --- a/drivers/tty/serial/samsung.c
48443 +++ b/drivers/tty/serial/samsung.c
48444 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48445 }
48446 }
48447
48448 +static int s3c64xx_serial_startup(struct uart_port *port);
48449 static int s3c24xx_serial_startup(struct uart_port *port)
48450 {
48451 struct s3c24xx_uart_port *ourport = to_ourport(port);
48452 int ret;
48453
48454 + /* Startup sequence is different for s3c64xx and higher SoC's */
48455 + if (s3c24xx_serial_has_interrupt_mask(port))
48456 + return s3c64xx_serial_startup(port);
48457 +
48458 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48459 port->mapbase, port->membase);
48460
48461 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48462 /* setup info for port */
48463 port->dev = &platdev->dev;
48464
48465 - /* Startup sequence is different for s3c64xx and higher SoC's */
48466 - if (s3c24xx_serial_has_interrupt_mask(port))
48467 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48468 -
48469 port->uartclk = 1;
48470
48471 if (cfg->uart_flags & UPF_CONS_FLOW) {
48472 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48473 index f87dbfd..42ad4b1 100644
48474 --- a/drivers/tty/serial/serial_core.c
48475 +++ b/drivers/tty/serial/serial_core.c
48476 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
48477 uart_flush_buffer(tty);
48478 uart_shutdown(tty, state);
48479 spin_lock_irqsave(&port->lock, flags);
48480 - port->count = 0;
48481 + atomic_set(&port->count, 0);
48482 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48483 spin_unlock_irqrestore(&port->lock, flags);
48484 tty_port_tty_set(port, NULL);
48485 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48486 goto end;
48487 }
48488
48489 - port->count++;
48490 + atomic_inc(&port->count);
48491 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48492 retval = -ENXIO;
48493 goto err_dec_count;
48494 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48495 /*
48496 * Make sure the device is in D0 state.
48497 */
48498 - if (port->count == 1)
48499 + if (atomic_read(&port->count) == 1)
48500 uart_change_pm(state, UART_PM_STATE_ON);
48501
48502 /*
48503 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48504 end:
48505 return retval;
48506 err_dec_count:
48507 - port->count--;
48508 + atomic_inc(&port->count);
48509 mutex_unlock(&port->mutex);
48510 goto end;
48511 }
48512 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48513 index 8eaf1ab..85c030d 100644
48514 --- a/drivers/tty/synclink.c
48515 +++ b/drivers/tty/synclink.c
48516 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48517
48518 if (debug_level >= DEBUG_LEVEL_INFO)
48519 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48520 - __FILE__,__LINE__, info->device_name, info->port.count);
48521 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48522
48523 if (tty_port_close_start(&info->port, tty, filp) == 0)
48524 goto cleanup;
48525 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48526 cleanup:
48527 if (debug_level >= DEBUG_LEVEL_INFO)
48528 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48529 - tty->driver->name, info->port.count);
48530 + tty->driver->name, atomic_read(&info->port.count));
48531
48532 } /* end of mgsl_close() */
48533
48534 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48535
48536 mgsl_flush_buffer(tty);
48537 shutdown(info);
48538 -
48539 - info->port.count = 0;
48540 +
48541 + atomic_set(&info->port.count, 0);
48542 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48543 info->port.tty = NULL;
48544
48545 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48546
48547 if (debug_level >= DEBUG_LEVEL_INFO)
48548 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48549 - __FILE__,__LINE__, tty->driver->name, port->count );
48550 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48551
48552 spin_lock_irqsave(&info->irq_spinlock, flags);
48553 if (!tty_hung_up_p(filp)) {
48554 extra_count = true;
48555 - port->count--;
48556 + atomic_dec(&port->count);
48557 }
48558 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48559 port->blocked_open++;
48560 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48561
48562 if (debug_level >= DEBUG_LEVEL_INFO)
48563 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48564 - __FILE__,__LINE__, tty->driver->name, port->count );
48565 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48566
48567 tty_unlock(tty);
48568 schedule();
48569 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48570
48571 /* FIXME: Racy on hangup during close wait */
48572 if (extra_count)
48573 - port->count++;
48574 + atomic_inc(&port->count);
48575 port->blocked_open--;
48576
48577 if (debug_level >= DEBUG_LEVEL_INFO)
48578 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48579 - __FILE__,__LINE__, tty->driver->name, port->count );
48580 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48581
48582 if (!retval)
48583 port->flags |= ASYNC_NORMAL_ACTIVE;
48584 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48585
48586 if (debug_level >= DEBUG_LEVEL_INFO)
48587 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48588 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48589 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48590
48591 /* If port is closing, signal caller to try again */
48592 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48593 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48594 spin_unlock_irqrestore(&info->netlock, flags);
48595 goto cleanup;
48596 }
48597 - info->port.count++;
48598 + atomic_inc(&info->port.count);
48599 spin_unlock_irqrestore(&info->netlock, flags);
48600
48601 - if (info->port.count == 1) {
48602 + if (atomic_read(&info->port.count) == 1) {
48603 /* 1st open on this device, init hardware */
48604 retval = startup(info);
48605 if (retval < 0)
48606 @@ -3446,8 +3446,8 @@ cleanup:
48607 if (retval) {
48608 if (tty->count == 1)
48609 info->port.tty = NULL; /* tty layer will release tty struct */
48610 - if(info->port.count)
48611 - info->port.count--;
48612 + if (atomic_read(&info->port.count))
48613 + atomic_dec(&info->port.count);
48614 }
48615
48616 return retval;
48617 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48618 unsigned short new_crctype;
48619
48620 /* return error if TTY interface open */
48621 - if (info->port.count)
48622 + if (atomic_read(&info->port.count))
48623 return -EBUSY;
48624
48625 switch (encoding)
48626 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48627
48628 /* arbitrate between network and tty opens */
48629 spin_lock_irqsave(&info->netlock, flags);
48630 - if (info->port.count != 0 || info->netcount != 0) {
48631 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48632 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48633 spin_unlock_irqrestore(&info->netlock, flags);
48634 return -EBUSY;
48635 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48636 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48637
48638 /* return error if TTY interface open */
48639 - if (info->port.count)
48640 + if (atomic_read(&info->port.count))
48641 return -EBUSY;
48642
48643 if (cmd != SIOCWANDEV)
48644 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48645 index 1abf946..1ee34fc 100644
48646 --- a/drivers/tty/synclink_gt.c
48647 +++ b/drivers/tty/synclink_gt.c
48648 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48649 tty->driver_data = info;
48650 info->port.tty = tty;
48651
48652 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48653 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48654
48655 /* If port is closing, signal caller to try again */
48656 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48657 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48658 mutex_unlock(&info->port.mutex);
48659 goto cleanup;
48660 }
48661 - info->port.count++;
48662 + atomic_inc(&info->port.count);
48663 spin_unlock_irqrestore(&info->netlock, flags);
48664
48665 - if (info->port.count == 1) {
48666 + if (atomic_read(&info->port.count) == 1) {
48667 /* 1st open on this device, init hardware */
48668 retval = startup(info);
48669 if (retval < 0) {
48670 @@ -715,8 +715,8 @@ cleanup:
48671 if (retval) {
48672 if (tty->count == 1)
48673 info->port.tty = NULL; /* tty layer will release tty struct */
48674 - if(info->port.count)
48675 - info->port.count--;
48676 + if(atomic_read(&info->port.count))
48677 + atomic_dec(&info->port.count);
48678 }
48679
48680 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48681 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48682
48683 if (sanity_check(info, tty->name, "close"))
48684 return;
48685 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48686 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48687
48688 if (tty_port_close_start(&info->port, tty, filp) == 0)
48689 goto cleanup;
48690 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48691 tty_port_close_end(&info->port, tty);
48692 info->port.tty = NULL;
48693 cleanup:
48694 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48695 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48696 }
48697
48698 static void hangup(struct tty_struct *tty)
48699 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48700 shutdown(info);
48701
48702 spin_lock_irqsave(&info->port.lock, flags);
48703 - info->port.count = 0;
48704 + atomic_set(&info->port.count, 0);
48705 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48706 info->port.tty = NULL;
48707 spin_unlock_irqrestore(&info->port.lock, flags);
48708 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48709 unsigned short new_crctype;
48710
48711 /* return error if TTY interface open */
48712 - if (info->port.count)
48713 + if (atomic_read(&info->port.count))
48714 return -EBUSY;
48715
48716 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48717 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48718
48719 /* arbitrate between network and tty opens */
48720 spin_lock_irqsave(&info->netlock, flags);
48721 - if (info->port.count != 0 || info->netcount != 0) {
48722 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48723 DBGINFO(("%s hdlc_open busy\n", dev->name));
48724 spin_unlock_irqrestore(&info->netlock, flags);
48725 return -EBUSY;
48726 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48727 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48728
48729 /* return error if TTY interface open */
48730 - if (info->port.count)
48731 + if (atomic_read(&info->port.count))
48732 return -EBUSY;
48733
48734 if (cmd != SIOCWANDEV)
48735 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48736 if (port == NULL)
48737 continue;
48738 spin_lock(&port->lock);
48739 - if ((port->port.count || port->netcount) &&
48740 + if ((atomic_read(&port->port.count) || port->netcount) &&
48741 port->pending_bh && !port->bh_running &&
48742 !port->bh_requested) {
48743 DBGISR(("%s bh queued\n", port->device_name));
48744 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48745 spin_lock_irqsave(&info->lock, flags);
48746 if (!tty_hung_up_p(filp)) {
48747 extra_count = true;
48748 - port->count--;
48749 + atomic_dec(&port->count);
48750 }
48751 spin_unlock_irqrestore(&info->lock, flags);
48752 port->blocked_open++;
48753 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48754 remove_wait_queue(&port->open_wait, &wait);
48755
48756 if (extra_count)
48757 - port->count++;
48758 + atomic_inc(&port->count);
48759 port->blocked_open--;
48760
48761 if (!retval)
48762 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48763 index ff17138..e38b41e 100644
48764 --- a/drivers/tty/synclinkmp.c
48765 +++ b/drivers/tty/synclinkmp.c
48766 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48767
48768 if (debug_level >= DEBUG_LEVEL_INFO)
48769 printk("%s(%d):%s open(), old ref count = %d\n",
48770 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48771 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48772
48773 /* If port is closing, signal caller to try again */
48774 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48775 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48776 spin_unlock_irqrestore(&info->netlock, flags);
48777 goto cleanup;
48778 }
48779 - info->port.count++;
48780 + atomic_inc(&info->port.count);
48781 spin_unlock_irqrestore(&info->netlock, flags);
48782
48783 - if (info->port.count == 1) {
48784 + if (atomic_read(&info->port.count) == 1) {
48785 /* 1st open on this device, init hardware */
48786 retval = startup(info);
48787 if (retval < 0)
48788 @@ -796,8 +796,8 @@ cleanup:
48789 if (retval) {
48790 if (tty->count == 1)
48791 info->port.tty = NULL; /* tty layer will release tty struct */
48792 - if(info->port.count)
48793 - info->port.count--;
48794 + if(atomic_read(&info->port.count))
48795 + atomic_dec(&info->port.count);
48796 }
48797
48798 return retval;
48799 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48800
48801 if (debug_level >= DEBUG_LEVEL_INFO)
48802 printk("%s(%d):%s close() entry, count=%d\n",
48803 - __FILE__,__LINE__, info->device_name, info->port.count);
48804 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48805
48806 if (tty_port_close_start(&info->port, tty, filp) == 0)
48807 goto cleanup;
48808 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48809 cleanup:
48810 if (debug_level >= DEBUG_LEVEL_INFO)
48811 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48812 - tty->driver->name, info->port.count);
48813 + tty->driver->name, atomic_read(&info->port.count));
48814 }
48815
48816 /* Called by tty_hangup() when a hangup is signaled.
48817 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48818 shutdown(info);
48819
48820 spin_lock_irqsave(&info->port.lock, flags);
48821 - info->port.count = 0;
48822 + atomic_set(&info->port.count, 0);
48823 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48824 info->port.tty = NULL;
48825 spin_unlock_irqrestore(&info->port.lock, flags);
48826 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48827 unsigned short new_crctype;
48828
48829 /* return error if TTY interface open */
48830 - if (info->port.count)
48831 + if (atomic_read(&info->port.count))
48832 return -EBUSY;
48833
48834 switch (encoding)
48835 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48836
48837 /* arbitrate between network and tty opens */
48838 spin_lock_irqsave(&info->netlock, flags);
48839 - if (info->port.count != 0 || info->netcount != 0) {
48840 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48841 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48842 spin_unlock_irqrestore(&info->netlock, flags);
48843 return -EBUSY;
48844 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48845 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48846
48847 /* return error if TTY interface open */
48848 - if (info->port.count)
48849 + if (atomic_read(&info->port.count))
48850 return -EBUSY;
48851
48852 if (cmd != SIOCWANDEV)
48853 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48854 * do not request bottom half processing if the
48855 * device is not open in a normal mode.
48856 */
48857 - if ( port && (port->port.count || port->netcount) &&
48858 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48859 port->pending_bh && !port->bh_running &&
48860 !port->bh_requested ) {
48861 if ( debug_level >= DEBUG_LEVEL_ISR )
48862 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48863
48864 if (debug_level >= DEBUG_LEVEL_INFO)
48865 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48866 - __FILE__,__LINE__, tty->driver->name, port->count );
48867 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48868
48869 spin_lock_irqsave(&info->lock, flags);
48870 if (!tty_hung_up_p(filp)) {
48871 extra_count = true;
48872 - port->count--;
48873 + atomic_dec(&port->count);
48874 }
48875 spin_unlock_irqrestore(&info->lock, flags);
48876 port->blocked_open++;
48877 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48878
48879 if (debug_level >= DEBUG_LEVEL_INFO)
48880 printk("%s(%d):%s block_til_ready() count=%d\n",
48881 - __FILE__,__LINE__, tty->driver->name, port->count );
48882 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48883
48884 tty_unlock(tty);
48885 schedule();
48886 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48887 remove_wait_queue(&port->open_wait, &wait);
48888
48889 if (extra_count)
48890 - port->count++;
48891 + atomic_inc(&port->count);
48892 port->blocked_open--;
48893
48894 if (debug_level >= DEBUG_LEVEL_INFO)
48895 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48896 - __FILE__,__LINE__, tty->driver->name, port->count );
48897 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48898
48899 if (!retval)
48900 port->flags |= ASYNC_NORMAL_ACTIVE;
48901 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48902 index b51c154..17d55d1 100644
48903 --- a/drivers/tty/sysrq.c
48904 +++ b/drivers/tty/sysrq.c
48905 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48906 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48907 size_t count, loff_t *ppos)
48908 {
48909 - if (count) {
48910 + if (count && capable(CAP_SYS_ADMIN)) {
48911 char c;
48912
48913 if (get_user(c, buf))
48914 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48915 index 4476682..d77e748 100644
48916 --- a/drivers/tty/tty_io.c
48917 +++ b/drivers/tty/tty_io.c
48918 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48919
48920 void tty_default_fops(struct file_operations *fops)
48921 {
48922 - *fops = tty_fops;
48923 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48924 }
48925
48926 /*
48927 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48928 index 1afe192..73d2c20 100644
48929 --- a/drivers/tty/tty_ldisc.c
48930 +++ b/drivers/tty/tty_ldisc.c
48931 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48932 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48933 tty_ldiscs[disc] = new_ldisc;
48934 new_ldisc->num = disc;
48935 - new_ldisc->refcount = 0;
48936 + atomic_set(&new_ldisc->refcount, 0);
48937 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48938
48939 return ret;
48940 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48941 return -EINVAL;
48942
48943 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48944 - if (tty_ldiscs[disc]->refcount)
48945 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48946 ret = -EBUSY;
48947 else
48948 tty_ldiscs[disc] = NULL;
48949 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48950 if (ldops) {
48951 ret = ERR_PTR(-EAGAIN);
48952 if (try_module_get(ldops->owner)) {
48953 - ldops->refcount++;
48954 + atomic_inc(&ldops->refcount);
48955 ret = ldops;
48956 }
48957 }
48958 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48959 unsigned long flags;
48960
48961 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48962 - ldops->refcount--;
48963 + atomic_dec(&ldops->refcount);
48964 module_put(ldops->owner);
48965 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48966 }
48967 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48968 /* unreleased reader reference(s) will cause this WARN */
48969 WARN_ON(!atomic_dec_and_test(&ld->users));
48970
48971 - ld->ops->refcount--;
48972 + atomic_dec(&ld->ops->refcount);
48973 module_put(ld->ops->owner);
48974 kfree(ld);
48975 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48976 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48977 index f597e88..b7f68ed 100644
48978 --- a/drivers/tty/tty_port.c
48979 +++ b/drivers/tty/tty_port.c
48980 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48981 unsigned long flags;
48982
48983 spin_lock_irqsave(&port->lock, flags);
48984 - port->count = 0;
48985 + atomic_set(&port->count, 0);
48986 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48987 tty = port->tty;
48988 if (tty)
48989 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48990 /* The port lock protects the port counts */
48991 spin_lock_irqsave(&port->lock, flags);
48992 if (!tty_hung_up_p(filp))
48993 - port->count--;
48994 + atomic_dec(&port->count);
48995 port->blocked_open++;
48996 spin_unlock_irqrestore(&port->lock, flags);
48997
48998 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48999 we must not mess that up further */
49000 spin_lock_irqsave(&port->lock, flags);
49001 if (!tty_hung_up_p(filp))
49002 - port->count++;
49003 + atomic_inc(&port->count);
49004 port->blocked_open--;
49005 if (retval == 0)
49006 port->flags |= ASYNC_NORMAL_ACTIVE;
49007 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
49008 return 0;
49009 }
49010
49011 - if (tty->count == 1 && port->count != 1) {
49012 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
49013 printk(KERN_WARNING
49014 "tty_port_close_start: tty->count = 1 port count = %d.\n",
49015 - port->count);
49016 - port->count = 1;
49017 + atomic_read(&port->count));
49018 + atomic_set(&port->count, 1);
49019 }
49020 - if (--port->count < 0) {
49021 + if (atomic_dec_return(&port->count) < 0) {
49022 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
49023 - port->count);
49024 - port->count = 0;
49025 + atomic_read(&port->count));
49026 + atomic_set(&port->count, 0);
49027 }
49028
49029 - if (port->count) {
49030 + if (atomic_read(&port->count)) {
49031 spin_unlock_irqrestore(&port->lock, flags);
49032 if (port->ops->drop)
49033 port->ops->drop(port);
49034 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
49035 {
49036 spin_lock_irq(&port->lock);
49037 if (!tty_hung_up_p(filp))
49038 - ++port->count;
49039 + atomic_inc(&port->count);
49040 spin_unlock_irq(&port->lock);
49041 tty_port_tty_set(port, tty);
49042
49043 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
49044 index a9af1b9a..1e08e7f 100644
49045 --- a/drivers/tty/vt/keyboard.c
49046 +++ b/drivers/tty/vt/keyboard.c
49047 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
49048 kbd->kbdmode == VC_OFF) &&
49049 value != KVAL(K_SAK))
49050 return; /* SAK is allowed even in raw mode */
49051 +
49052 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
49053 + {
49054 + void *func = fn_handler[value];
49055 + if (func == fn_show_state || func == fn_show_ptregs ||
49056 + func == fn_show_mem)
49057 + return;
49058 + }
49059 +#endif
49060 +
49061 fn_handler[value](vc);
49062 }
49063
49064 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49065 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
49066 return -EFAULT;
49067
49068 - if (!capable(CAP_SYS_TTY_CONFIG))
49069 - perm = 0;
49070 -
49071 switch (cmd) {
49072 case KDGKBENT:
49073 /* Ensure another thread doesn't free it under us */
49074 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49075 spin_unlock_irqrestore(&kbd_event_lock, flags);
49076 return put_user(val, &user_kbe->kb_value);
49077 case KDSKBENT:
49078 + if (!capable(CAP_SYS_TTY_CONFIG))
49079 + perm = 0;
49080 +
49081 if (!perm)
49082 return -EPERM;
49083 if (!i && v == K_NOSUCHMAP) {
49084 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49085 int i, j, k;
49086 int ret;
49087
49088 - if (!capable(CAP_SYS_TTY_CONFIG))
49089 - perm = 0;
49090 -
49091 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
49092 if (!kbs) {
49093 ret = -ENOMEM;
49094 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49095 kfree(kbs);
49096 return ((p && *p) ? -EOVERFLOW : 0);
49097 case KDSKBSENT:
49098 + if (!capable(CAP_SYS_TTY_CONFIG))
49099 + perm = 0;
49100 +
49101 if (!perm) {
49102 ret = -EPERM;
49103 goto reterr;
49104 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
49105 index b645c47..a55c182 100644
49106 --- a/drivers/uio/uio.c
49107 +++ b/drivers/uio/uio.c
49108 @@ -25,6 +25,7 @@
49109 #include <linux/kobject.h>
49110 #include <linux/cdev.h>
49111 #include <linux/uio_driver.h>
49112 +#include <asm/local.h>
49113
49114 #define UIO_MAX_DEVICES (1U << MINORBITS)
49115
49116 @@ -32,10 +33,10 @@ struct uio_device {
49117 struct module *owner;
49118 struct device *dev;
49119 int minor;
49120 - atomic_t event;
49121 + atomic_unchecked_t event;
49122 struct fasync_struct *async_queue;
49123 wait_queue_head_t wait;
49124 - int vma_count;
49125 + local_t vma_count;
49126 struct uio_info *info;
49127 struct kobject *map_dir;
49128 struct kobject *portio_dir;
49129 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
49130 struct device_attribute *attr, char *buf)
49131 {
49132 struct uio_device *idev = dev_get_drvdata(dev);
49133 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
49134 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
49135 }
49136
49137 static struct device_attribute uio_class_attributes[] = {
49138 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
49139 {
49140 struct uio_device *idev = info->uio_dev;
49141
49142 - atomic_inc(&idev->event);
49143 + atomic_inc_unchecked(&idev->event);
49144 wake_up_interruptible(&idev->wait);
49145 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
49146 }
49147 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
49148 }
49149
49150 listener->dev = idev;
49151 - listener->event_count = atomic_read(&idev->event);
49152 + listener->event_count = atomic_read_unchecked(&idev->event);
49153 filep->private_data = listener;
49154
49155 if (idev->info->open) {
49156 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49157 return -EIO;
49158
49159 poll_wait(filep, &idev->wait, wait);
49160 - if (listener->event_count != atomic_read(&idev->event))
49161 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49162 return POLLIN | POLLRDNORM;
49163 return 0;
49164 }
49165 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49166 do {
49167 set_current_state(TASK_INTERRUPTIBLE);
49168
49169 - event_count = atomic_read(&idev->event);
49170 + event_count = atomic_read_unchecked(&idev->event);
49171 if (event_count != listener->event_count) {
49172 if (copy_to_user(buf, &event_count, count))
49173 retval = -EFAULT;
49174 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
49175 static void uio_vma_open(struct vm_area_struct *vma)
49176 {
49177 struct uio_device *idev = vma->vm_private_data;
49178 - idev->vma_count++;
49179 + local_inc(&idev->vma_count);
49180 }
49181
49182 static void uio_vma_close(struct vm_area_struct *vma)
49183 {
49184 struct uio_device *idev = vma->vm_private_data;
49185 - idev->vma_count--;
49186 + local_dec(&idev->vma_count);
49187 }
49188
49189 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
49190 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
49191 idev->owner = owner;
49192 idev->info = info;
49193 init_waitqueue_head(&idev->wait);
49194 - atomic_set(&idev->event, 0);
49195 + atomic_set_unchecked(&idev->event, 0);
49196
49197 ret = uio_get_minor(idev);
49198 if (ret)
49199 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49200 index 8a7eb77..c00402f 100644
49201 --- a/drivers/usb/atm/cxacru.c
49202 +++ b/drivers/usb/atm/cxacru.c
49203 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49204 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49205 if (ret < 2)
49206 return -EINVAL;
49207 - if (index < 0 || index > 0x7f)
49208 + if (index > 0x7f)
49209 return -EINVAL;
49210 pos += tmp;
49211
49212 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49213 index d3527dd..26effa2 100644
49214 --- a/drivers/usb/atm/usbatm.c
49215 +++ b/drivers/usb/atm/usbatm.c
49216 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49217 if (printk_ratelimit())
49218 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49219 __func__, vpi, vci);
49220 - atomic_inc(&vcc->stats->rx_err);
49221 + atomic_inc_unchecked(&vcc->stats->rx_err);
49222 return;
49223 }
49224
49225 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49226 if (length > ATM_MAX_AAL5_PDU) {
49227 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49228 __func__, length, vcc);
49229 - atomic_inc(&vcc->stats->rx_err);
49230 + atomic_inc_unchecked(&vcc->stats->rx_err);
49231 goto out;
49232 }
49233
49234 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49235 if (sarb->len < pdu_length) {
49236 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49237 __func__, pdu_length, sarb->len, vcc);
49238 - atomic_inc(&vcc->stats->rx_err);
49239 + atomic_inc_unchecked(&vcc->stats->rx_err);
49240 goto out;
49241 }
49242
49243 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49244 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49245 __func__, vcc);
49246 - atomic_inc(&vcc->stats->rx_err);
49247 + atomic_inc_unchecked(&vcc->stats->rx_err);
49248 goto out;
49249 }
49250
49251 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49252 if (printk_ratelimit())
49253 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49254 __func__, length);
49255 - atomic_inc(&vcc->stats->rx_drop);
49256 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49257 goto out;
49258 }
49259
49260 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49261
49262 vcc->push(vcc, skb);
49263
49264 - atomic_inc(&vcc->stats->rx);
49265 + atomic_inc_unchecked(&vcc->stats->rx);
49266 out:
49267 skb_trim(sarb, 0);
49268 }
49269 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
49270 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49271
49272 usbatm_pop(vcc, skb);
49273 - atomic_inc(&vcc->stats->tx);
49274 + atomic_inc_unchecked(&vcc->stats->tx);
49275
49276 skb = skb_dequeue(&instance->sndqueue);
49277 }
49278 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49279 if (!left--)
49280 return sprintf(page,
49281 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49282 - atomic_read(&atm_dev->stats.aal5.tx),
49283 - atomic_read(&atm_dev->stats.aal5.tx_err),
49284 - atomic_read(&atm_dev->stats.aal5.rx),
49285 - atomic_read(&atm_dev->stats.aal5.rx_err),
49286 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49287 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49288 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49289 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49290 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49291 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49292
49293 if (!left--) {
49294 if (instance->disconnected)
49295 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49296 index 2a3bbdf..91d72cf 100644
49297 --- a/drivers/usb/core/devices.c
49298 +++ b/drivers/usb/core/devices.c
49299 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49300 * time it gets called.
49301 */
49302 static struct device_connect_event {
49303 - atomic_t count;
49304 + atomic_unchecked_t count;
49305 wait_queue_head_t wait;
49306 } device_event = {
49307 .count = ATOMIC_INIT(1),
49308 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49309
49310 void usbfs_conn_disc_event(void)
49311 {
49312 - atomic_add(2, &device_event.count);
49313 + atomic_add_unchecked(2, &device_event.count);
49314 wake_up(&device_event.wait);
49315 }
49316
49317 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49318
49319 poll_wait(file, &device_event.wait, wait);
49320
49321 - event_count = atomic_read(&device_event.count);
49322 + event_count = atomic_read_unchecked(&device_event.count);
49323 if (file->f_version != event_count) {
49324 file->f_version = event_count;
49325 return POLLIN | POLLRDNORM;
49326 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49327 index d53547d..6a22d02 100644
49328 --- a/drivers/usb/core/hcd.c
49329 +++ b/drivers/usb/core/hcd.c
49330 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49331 */
49332 usb_get_urb(urb);
49333 atomic_inc(&urb->use_count);
49334 - atomic_inc(&urb->dev->urbnum);
49335 + atomic_inc_unchecked(&urb->dev->urbnum);
49336 usbmon_urb_submit(&hcd->self, urb);
49337
49338 /* NOTE requirements on root-hub callers (usbfs and the hub
49339 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49340 urb->hcpriv = NULL;
49341 INIT_LIST_HEAD(&urb->urb_list);
49342 atomic_dec(&urb->use_count);
49343 - atomic_dec(&urb->dev->urbnum);
49344 + atomic_dec_unchecked(&urb->dev->urbnum);
49345 if (atomic_read(&urb->reject))
49346 wake_up(&usb_kill_urb_queue);
49347 usb_put_urb(urb);
49348 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49349 index da2905a..834a569 100644
49350 --- a/drivers/usb/core/hub.c
49351 +++ b/drivers/usb/core/hub.c
49352 @@ -27,6 +27,7 @@
49353 #include <linux/freezer.h>
49354 #include <linux/random.h>
49355 #include <linux/pm_qos.h>
49356 +#include <linux/grsecurity.h>
49357
49358 #include <asm/uaccess.h>
49359 #include <asm/byteorder.h>
49360 @@ -4424,6 +4425,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49361 goto done;
49362 return;
49363 }
49364 +
49365 + if (gr_handle_new_usb())
49366 + goto done;
49367 +
49368 if (hub_is_superspeed(hub->hdev))
49369 unit_load = 150;
49370 else
49371 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49372 index 444d30e..f15c850 100644
49373 --- a/drivers/usb/core/message.c
49374 +++ b/drivers/usb/core/message.c
49375 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49376 * method can wait for it to complete. Since you don't have a handle on the
49377 * URB used, you can't cancel the request.
49378 */
49379 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49380 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49381 __u8 requesttype, __u16 value, __u16 index, void *data,
49382 __u16 size, int timeout)
49383 {
49384 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49385 index aa38db4..0a08682 100644
49386 --- a/drivers/usb/core/sysfs.c
49387 +++ b/drivers/usb/core/sysfs.c
49388 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49389 struct usb_device *udev;
49390
49391 udev = to_usb_device(dev);
49392 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49393 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49394 }
49395 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49396
49397 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49398 index b10da72..43aa0b2 100644
49399 --- a/drivers/usb/core/usb.c
49400 +++ b/drivers/usb/core/usb.c
49401 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49402 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49403 dev->state = USB_STATE_ATTACHED;
49404 dev->lpm_disable_count = 1;
49405 - atomic_set(&dev->urbnum, 0);
49406 + atomic_set_unchecked(&dev->urbnum, 0);
49407
49408 INIT_LIST_HEAD(&dev->ep0.urb_list);
49409 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49410 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49411 index f77083f..f3e2e34 100644
49412 --- a/drivers/usb/dwc3/gadget.c
49413 +++ b/drivers/usb/dwc3/gadget.c
49414 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49415 if (!usb_endpoint_xfer_isoc(desc))
49416 return 0;
49417
49418 - memset(&trb_link, 0, sizeof(trb_link));
49419 -
49420 /* Link TRB for ISOC. The HWO bit is never reset */
49421 trb_st_hw = &dep->trb_pool[0];
49422
49423 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49424 index 5e29dde..eca992f 100644
49425 --- a/drivers/usb/early/ehci-dbgp.c
49426 +++ b/drivers/usb/early/ehci-dbgp.c
49427 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49428
49429 #ifdef CONFIG_KGDB
49430 static struct kgdb_io kgdbdbgp_io_ops;
49431 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49432 +static struct kgdb_io kgdbdbgp_io_ops_console;
49433 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49434 #else
49435 #define dbgp_kgdb_mode (0)
49436 #endif
49437 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49438 .write_char = kgdbdbgp_write_char,
49439 };
49440
49441 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49442 + .name = "kgdbdbgp",
49443 + .read_char = kgdbdbgp_read_char,
49444 + .write_char = kgdbdbgp_write_char,
49445 + .is_console = 1
49446 +};
49447 +
49448 static int kgdbdbgp_wait_time;
49449
49450 static int __init kgdbdbgp_parse_config(char *str)
49451 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49452 ptr++;
49453 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49454 }
49455 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49456 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49457 + if (early_dbgp_console.index != -1)
49458 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49459 + else
49460 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49461
49462 return 0;
49463 }
49464 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49465 index b369292..9f3ba40 100644
49466 --- a/drivers/usb/gadget/u_serial.c
49467 +++ b/drivers/usb/gadget/u_serial.c
49468 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49469 spin_lock_irq(&port->port_lock);
49470
49471 /* already open? Great. */
49472 - if (port->port.count) {
49473 + if (atomic_read(&port->port.count)) {
49474 status = 0;
49475 - port->port.count++;
49476 + atomic_inc(&port->port.count);
49477
49478 /* currently opening/closing? wait ... */
49479 } else if (port->openclose) {
49480 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49481 tty->driver_data = port;
49482 port->port.tty = tty;
49483
49484 - port->port.count = 1;
49485 + atomic_set(&port->port.count, 1);
49486 port->openclose = false;
49487
49488 /* if connected, start the I/O stream */
49489 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49490
49491 spin_lock_irq(&port->port_lock);
49492
49493 - if (port->port.count != 1) {
49494 - if (port->port.count == 0)
49495 + if (atomic_read(&port->port.count) != 1) {
49496 + if (atomic_read(&port->port.count) == 0)
49497 WARN_ON(1);
49498 else
49499 - --port->port.count;
49500 + atomic_dec(&port->port.count);
49501 goto exit;
49502 }
49503
49504 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49505 * and sleep if necessary
49506 */
49507 port->openclose = true;
49508 - port->port.count = 0;
49509 + atomic_set(&port->port.count, 0);
49510
49511 gser = port->port_usb;
49512 if (gser && gser->disconnect)
49513 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49514 int cond;
49515
49516 spin_lock_irq(&port->port_lock);
49517 - cond = (port->port.count == 0) && !port->openclose;
49518 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49519 spin_unlock_irq(&port->port_lock);
49520 return cond;
49521 }
49522 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49523 /* if it's already open, start I/O ... and notify the serial
49524 * protocol about open/close status (connect/disconnect).
49525 */
49526 - if (port->port.count) {
49527 + if (atomic_read(&port->port.count)) {
49528 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49529 gs_start_io(port);
49530 if (gser->connect)
49531 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49532
49533 port->port_usb = NULL;
49534 gser->ioport = NULL;
49535 - if (port->port.count > 0 || port->openclose) {
49536 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49537 wake_up_interruptible(&port->drain_wait);
49538 if (port->port.tty)
49539 tty_hangup(port->port.tty);
49540 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49541
49542 /* finally, free any unused/unusable I/O buffers */
49543 spin_lock_irqsave(&port->port_lock, flags);
49544 - if (port->port.count == 0 && !port->openclose)
49545 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49546 gs_buf_free(&port->port_write_buf);
49547 gs_free_requests(gser->out, &port->read_pool, NULL);
49548 gs_free_requests(gser->out, &port->read_queue, NULL);
49549 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49550 index ba6a5d6..f88f7f3 100644
49551 --- a/drivers/usb/misc/appledisplay.c
49552 +++ b/drivers/usb/misc/appledisplay.c
49553 @@ -83,7 +83,7 @@ struct appledisplay {
49554 spinlock_t lock;
49555 };
49556
49557 -static atomic_t count_displays = ATOMIC_INIT(0);
49558 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49559 static struct workqueue_struct *wq;
49560
49561 static void appledisplay_complete(struct urb *urb)
49562 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49563
49564 /* Register backlight device */
49565 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49566 - atomic_inc_return(&count_displays) - 1);
49567 + atomic_inc_return_unchecked(&count_displays) - 1);
49568 memset(&props, 0, sizeof(struct backlight_properties));
49569 props.type = BACKLIGHT_RAW;
49570 props.max_brightness = 0xff;
49571 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49572 index 5f3bcd3..bfca43f 100644
49573 --- a/drivers/usb/serial/console.c
49574 +++ b/drivers/usb/serial/console.c
49575 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49576
49577 info->port = port;
49578
49579 - ++port->port.count;
49580 + atomic_inc(&port->port.count);
49581 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49582 if (serial->type->set_termios) {
49583 /*
49584 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49585 }
49586 /* Now that any required fake tty operations are completed restore
49587 * the tty port count */
49588 - --port->port.count;
49589 + atomic_dec(&port->port.count);
49590 /* The console is special in terms of closing the device so
49591 * indicate this port is now acting as a system console. */
49592 port->port.console = 1;
49593 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49594 free_tty:
49595 kfree(tty);
49596 reset_open_count:
49597 - port->port.count = 0;
49598 + atomic_set(&port->port.count, 0);
49599 usb_autopm_put_interface(serial->interface);
49600 error_get_interface:
49601 usb_serial_put(serial);
49602 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49603 index 75f70f0..d467e1a 100644
49604 --- a/drivers/usb/storage/usb.h
49605 +++ b/drivers/usb/storage/usb.h
49606 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49607 __u8 useProtocol;
49608 __u8 useTransport;
49609 int (*initFunction)(struct us_data *);
49610 -};
49611 +} __do_const;
49612
49613
49614 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49615 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49616 index d6bea3e..60b250e 100644
49617 --- a/drivers/usb/wusbcore/wa-hc.h
49618 +++ b/drivers/usb/wusbcore/wa-hc.h
49619 @@ -192,7 +192,7 @@ struct wahc {
49620 struct list_head xfer_delayed_list;
49621 spinlock_t xfer_list_lock;
49622 struct work_struct xfer_work;
49623 - atomic_t xfer_id_count;
49624 + atomic_unchecked_t xfer_id_count;
49625 };
49626
49627
49628 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49629 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49630 spin_lock_init(&wa->xfer_list_lock);
49631 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49632 - atomic_set(&wa->xfer_id_count, 1);
49633 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49634 }
49635
49636 /**
49637 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49638 index 028fc83..65bb105 100644
49639 --- a/drivers/usb/wusbcore/wa-xfer.c
49640 +++ b/drivers/usb/wusbcore/wa-xfer.c
49641 @@ -296,7 +296,7 @@ out:
49642 */
49643 static void wa_xfer_id_init(struct wa_xfer *xfer)
49644 {
49645 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49646 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49647 }
49648
49649 /*
49650 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49651 index 6d78736..65be90e 100644
49652 --- a/drivers/vfio/vfio.c
49653 +++ b/drivers/vfio/vfio.c
49654 @@ -486,7 +486,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49655 return 0;
49656
49657 /* TODO Prevent device auto probing */
49658 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49659 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49660 iommu_group_id(group->iommu_group));
49661
49662 return 0;
49663 @@ -506,7 +506,7 @@ static int vfio_group_nb_del_dev(struct vfio_group *group, struct device *dev)
49664 if (likely(!device))
49665 return 0;
49666
49667 - WARN("Device %s removed from live group %d!\n", dev_name(dev),
49668 + WARN(1, "Device %s removed from live group %d!\n", dev_name(dev),
49669 iommu_group_id(group->iommu_group));
49670
49671 vfio_device_put(device);
49672 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49673 index 5174eba..86e764a 100644
49674 --- a/drivers/vhost/vringh.c
49675 +++ b/drivers/vhost/vringh.c
49676 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49677
49678 static inline int putu16_kern(u16 *p, u16 val)
49679 {
49680 - ACCESS_ONCE(*p) = val;
49681 + ACCESS_ONCE_RW(*p) = val;
49682 return 0;
49683 }
49684
49685 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49686 index 8c55011..eed4ae1a 100644
49687 --- a/drivers/video/aty/aty128fb.c
49688 +++ b/drivers/video/aty/aty128fb.c
49689 @@ -149,7 +149,7 @@ enum {
49690 };
49691
49692 /* Must match above enum */
49693 -static char * const r128_family[] = {
49694 +static const char * const r128_family[] = {
49695 "AGP",
49696 "PCI",
49697 "PRO AGP",
49698 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49699 index 4f27fdc..d3537e6 100644
49700 --- a/drivers/video/aty/atyfb_base.c
49701 +++ b/drivers/video/aty/atyfb_base.c
49702 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
49703 par->accel_flags = var->accel_flags; /* hack */
49704
49705 if (var->accel_flags) {
49706 - info->fbops->fb_sync = atyfb_sync;
49707 + pax_open_kernel();
49708 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49709 + pax_close_kernel();
49710 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49711 } else {
49712 - info->fbops->fb_sync = NULL;
49713 + pax_open_kernel();
49714 + *(void **)&info->fbops->fb_sync = NULL;
49715 + pax_close_kernel();
49716 info->flags |= FBINFO_HWACCEL_DISABLED;
49717 }
49718
49719 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49720 index 95ec042..e6affdd 100644
49721 --- a/drivers/video/aty/mach64_cursor.c
49722 +++ b/drivers/video/aty/mach64_cursor.c
49723 @@ -7,6 +7,7 @@
49724 #include <linux/string.h>
49725
49726 #include <asm/io.h>
49727 +#include <asm/pgtable.h>
49728
49729 #ifdef __sparc__
49730 #include <asm/fbio.h>
49731 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49732 info->sprite.buf_align = 16; /* and 64 lines tall. */
49733 info->sprite.flags = FB_PIXMAP_IO;
49734
49735 - info->fbops->fb_cursor = atyfb_cursor;
49736 + pax_open_kernel();
49737 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49738 + pax_close_kernel();
49739
49740 return 0;
49741 }
49742 diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
49743 index c74e7aa..e3c2790 100644
49744 --- a/drivers/video/backlight/backlight.c
49745 +++ b/drivers/video/backlight/backlight.c
49746 @@ -304,7 +304,7 @@ struct backlight_device *backlight_device_register(const char *name,
49747 new_bd->dev.class = backlight_class;
49748 new_bd->dev.parent = parent;
49749 new_bd->dev.release = bl_device_release;
49750 - dev_set_name(&new_bd->dev, name);
49751 + dev_set_name(&new_bd->dev, "%s", name);
49752 dev_set_drvdata(&new_bd->dev, devdata);
49753
49754 /* Set default properties */
49755 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49756 index bca6ccc..252107e 100644
49757 --- a/drivers/video/backlight/kb3886_bl.c
49758 +++ b/drivers/video/backlight/kb3886_bl.c
49759 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49760 static unsigned long kb3886bl_flags;
49761 #define KB3886BL_SUSPENDED 0x01
49762
49763 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49764 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49765 {
49766 .ident = "Sahara Touch-iT",
49767 .matches = {
49768 diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
49769 index 34fb6bd..3649fd9 100644
49770 --- a/drivers/video/backlight/lcd.c
49771 +++ b/drivers/video/backlight/lcd.c
49772 @@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
49773 new_ld->dev.class = lcd_class;
49774 new_ld->dev.parent = parent;
49775 new_ld->dev.release = lcd_device_release;
49776 - dev_set_name(&new_ld->dev, name);
49777 + dev_set_name(&new_ld->dev, "%s", name);
49778 dev_set_drvdata(&new_ld->dev, devdata);
49779
49780 rc = device_register(&new_ld->dev);
49781 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49782 index 900aa4e..6d49418 100644
49783 --- a/drivers/video/fb_defio.c
49784 +++ b/drivers/video/fb_defio.c
49785 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49786
49787 BUG_ON(!fbdefio);
49788 mutex_init(&fbdefio->lock);
49789 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49790 + pax_open_kernel();
49791 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49792 + pax_close_kernel();
49793 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49794 INIT_LIST_HEAD(&fbdefio->pagelist);
49795 if (fbdefio->delay == 0) /* set a default of 1 s */
49796 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49797 page->mapping = NULL;
49798 }
49799
49800 - info->fbops->fb_mmap = NULL;
49801 + *(void **)&info->fbops->fb_mmap = NULL;
49802 mutex_destroy(&fbdefio->lock);
49803 }
49804 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49805 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49806 index 5c3960d..15cf8fc 100644
49807 --- a/drivers/video/fbcmap.c
49808 +++ b/drivers/video/fbcmap.c
49809 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49810 rc = -ENODEV;
49811 goto out;
49812 }
49813 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49814 - !info->fbops->fb_setcmap)) {
49815 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49816 rc = -EINVAL;
49817 goto out1;
49818 }
49819 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49820 index 098bfc6..796841d 100644
49821 --- a/drivers/video/fbmem.c
49822 +++ b/drivers/video/fbmem.c
49823 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49824 image->dx += image->width + 8;
49825 }
49826 } else if (rotate == FB_ROTATE_UD) {
49827 - for (x = 0; x < num && image->dx >= 0; x++) {
49828 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49829 info->fbops->fb_imageblit(info, image);
49830 image->dx -= image->width + 8;
49831 }
49832 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49833 image->dy += image->height + 8;
49834 }
49835 } else if (rotate == FB_ROTATE_CCW) {
49836 - for (x = 0; x < num && image->dy >= 0; x++) {
49837 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49838 info->fbops->fb_imageblit(info, image);
49839 image->dy -= image->height + 8;
49840 }
49841 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49842 return -EFAULT;
49843 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49844 return -EINVAL;
49845 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49846 + if (con2fb.framebuffer >= FB_MAX)
49847 return -EINVAL;
49848 if (!registered_fb[con2fb.framebuffer])
49849 request_module("fb%d", con2fb.framebuffer);
49850 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49851 index d4d2c5f..ebbd113 100644
49852 --- a/drivers/video/hyperv_fb.c
49853 +++ b/drivers/video/hyperv_fb.c
49854 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49855 static inline int synthvid_send(struct hv_device *hdev,
49856 struct synthvid_msg *msg)
49857 {
49858 - static atomic64_t request_id = ATOMIC64_INIT(0);
49859 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49860 int ret;
49861
49862 msg->pipe_hdr.type = PIPE_MSG_DATA;
49863 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49864
49865 ret = vmbus_sendpacket(hdev->channel, msg,
49866 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49867 - atomic64_inc_return(&request_id),
49868 + atomic64_inc_return_unchecked(&request_id),
49869 VM_PKT_DATA_INBAND, 0);
49870
49871 if (ret)
49872 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49873 index 7672d2e..b56437f 100644
49874 --- a/drivers/video/i810/i810_accel.c
49875 +++ b/drivers/video/i810/i810_accel.c
49876 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49877 }
49878 }
49879 printk("ringbuffer lockup!!!\n");
49880 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49881 i810_report_error(mmio);
49882 par->dev_flags |= LOCKUP;
49883 info->pixmap.scan_align = 1;
49884 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49885 index 3c14e43..eafa544 100644
49886 --- a/drivers/video/logo/logo_linux_clut224.ppm
49887 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49888 @@ -1,1604 +1,1123 @@
49889 P3
49890 -# Standard 224-color Linux logo
49891 80 80
49892 255
49893 - 0 0 0 0 0 0 0 0 0 0 0 0
49894 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 6 6 6 10 10 10 10 10 10
49903 - 10 10 10 6 6 6 6 6 6 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
49910 - 0 0 0 0 0 0 0 0 0 0 0 0
49911 - 0 0 0 0 0 0 0 0 0 0 0 0
49912 - 0 0 0 0 0 0 0 0 0 0 0 0
49913 - 0 0 0 0 0 0 0 0 0 0 0 0
49914 - 0 0 0 0 0 0 0 0 0 0 0 0
49915 - 0 0 0 0 0 0 0 0 0 0 0 0
49916 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 10 10 10 14 14 14
49922 - 22 22 22 26 26 26 30 30 30 34 34 34
49923 - 30 30 30 30 30 30 26 26 26 18 18 18
49924 - 14 14 14 10 10 10 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
49930 - 0 0 0 0 0 0 0 0 0 0 0 0
49931 - 0 0 0 0 0 0 0 0 0 0 0 0
49932 - 0 0 0 0 0 0 0 0 0 0 0 0
49933 - 0 0 0 0 0 0 0 0 0 0 0 0
49934 - 0 0 0 0 0 1 0 0 1 0 0 0
49935 - 0 0 0 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 - 6 6 6 14 14 14 26 26 26 42 42 42
49942 - 54 54 54 66 66 66 78 78 78 78 78 78
49943 - 78 78 78 74 74 74 66 66 66 54 54 54
49944 - 42 42 42 26 26 26 18 18 18 10 10 10
49945 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
49950 - 0 0 0 0 0 0 0 0 0 0 0 0
49951 - 0 0 0 0 0 0 0 0 0 0 0 0
49952 - 0 0 0 0 0 0 0 0 0 0 0 0
49953 - 0 0 0 0 0 0 0 0 0 0 0 0
49954 - 0 0 1 0 0 0 0 0 0 0 0 0
49955 - 0 0 0 0 0 0 0 0 0 0 0 0
49956 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
49961 - 22 22 22 42 42 42 66 66 66 86 86 86
49962 - 66 66 66 38 38 38 38 38 38 22 22 22
49963 - 26 26 26 34 34 34 54 54 54 66 66 66
49964 - 86 86 86 70 70 70 46 46 46 26 26 26
49965 - 14 14 14 6 6 6 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 0 0 0
49969 - 0 0 0 0 0 0 0 0 0 0 0 0
49970 - 0 0 0 0 0 0 0 0 0 0 0 0
49971 - 0 0 0 0 0 0 0 0 0 0 0 0
49972 - 0 0 0 0 0 0 0 0 0 0 0 0
49973 - 0 0 0 0 0 0 0 0 0 0 0 0
49974 - 0 0 1 0 0 1 0 0 1 0 0 0
49975 - 0 0 0 0 0 0 0 0 0 0 0 0
49976 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10 26 26 26
49981 - 50 50 50 82 82 82 58 58 58 6 6 6
49982 - 2 2 6 2 2 6 2 2 6 2 2 6
49983 - 2 2 6 2 2 6 2 2 6 2 2 6
49984 - 6 6 6 54 54 54 86 86 86 66 66 66
49985 - 38 38 38 18 18 18 6 6 6 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 0 0 0
49989 - 0 0 0 0 0 0 0 0 0 0 0 0
49990 - 0 0 0 0 0 0 0 0 0 0 0 0
49991 - 0 0 0 0 0 0 0 0 0 0 0 0
49992 - 0 0 0 0 0 0 0 0 0 0 0 0
49993 - 0 0 0 0 0 0 0 0 0 0 0 0
49994 - 0 0 0 0 0 0 0 0 0 0 0 0
49995 - 0 0 0 0 0 0 0 0 0 0 0 0
49996 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 22 22 22 50 50 50
50001 - 78 78 78 34 34 34 2 2 6 2 2 6
50002 - 2 2 6 2 2 6 2 2 6 2 2 6
50003 - 2 2 6 2 2 6 2 2 6 2 2 6
50004 - 2 2 6 2 2 6 6 6 6 70 70 70
50005 - 78 78 78 46 46 46 22 22 22 6 6 6
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 0 0 0
50009 - 0 0 0 0 0 0 0 0 0 0 0 0
50010 - 0 0 0 0 0 0 0 0 0 0 0 0
50011 - 0 0 0 0 0 0 0 0 0 0 0 0
50012 - 0 0 0 0 0 0 0 0 0 0 0 0
50013 - 0 0 0 0 0 0 0 0 0 0 0 0
50014 - 0 0 1 0 0 1 0 0 1 0 0 0
50015 - 0 0 0 0 0 0 0 0 0 0 0 0
50016 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 18 18 18 42 42 42 82 82 82
50021 - 26 26 26 2 2 6 2 2 6 2 2 6
50022 - 2 2 6 2 2 6 2 2 6 2 2 6
50023 - 2 2 6 2 2 6 2 2 6 14 14 14
50024 - 46 46 46 34 34 34 6 6 6 2 2 6
50025 - 42 42 42 78 78 78 42 42 42 18 18 18
50026 - 6 6 6 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 0 0 0
50029 - 0 0 0 0 0 0 0 0 0 0 0 0
50030 - 0 0 0 0 0 0 0 0 0 0 0 0
50031 - 0 0 0 0 0 0 0 0 0 0 0 0
50032 - 0 0 0 0 0 0 0 0 0 0 0 0
50033 - 0 0 0 0 0 0 0 0 0 0 0 0
50034 - 0 0 1 0 0 0 0 0 1 0 0 0
50035 - 0 0 0 0 0 0 0 0 0 0 0 0
50036 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 10 10 10 30 30 30 66 66 66 58 58 58
50041 - 2 2 6 2 2 6 2 2 6 2 2 6
50042 - 2 2 6 2 2 6 2 2 6 2 2 6
50043 - 2 2 6 2 2 6 2 2 6 26 26 26
50044 - 86 86 86 101 101 101 46 46 46 10 10 10
50045 - 2 2 6 58 58 58 70 70 70 34 34 34
50046 - 10 10 10 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 0 0 0
50049 - 0 0 0 0 0 0 0 0 0 0 0 0
50050 - 0 0 0 0 0 0 0 0 0 0 0 0
50051 - 0 0 0 0 0 0 0 0 0 0 0 0
50052 - 0 0 0 0 0 0 0 0 0 0 0 0
50053 - 0 0 0 0 0 0 0 0 0 0 0 0
50054 - 0 0 1 0 0 1 0 0 1 0 0 0
50055 - 0 0 0 0 0 0 0 0 0 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 - 14 14 14 42 42 42 86 86 86 10 10 10
50061 - 2 2 6 2 2 6 2 2 6 2 2 6
50062 - 2 2 6 2 2 6 2 2 6 2 2 6
50063 - 2 2 6 2 2 6 2 2 6 30 30 30
50064 - 94 94 94 94 94 94 58 58 58 26 26 26
50065 - 2 2 6 6 6 6 78 78 78 54 54 54
50066 - 22 22 22 6 6 6 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 0 0 0
50069 - 0 0 0 0 0 0 0 0 0 0 0 0
50070 - 0 0 0 0 0 0 0 0 0 0 0 0
50071 - 0 0 0 0 0 0 0 0 0 0 0 0
50072 - 0 0 0 0 0 0 0 0 0 0 0 0
50073 - 0 0 0 0 0 0 0 0 0 0 0 0
50074 - 0 0 0 0 0 0 0 0 0 0 0 0
50075 - 0 0 0 0 0 0 0 0 0 0 0 0
50076 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
50080 - 22 22 22 62 62 62 62 62 62 2 2 6
50081 - 2 2 6 2 2 6 2 2 6 2 2 6
50082 - 2 2 6 2 2 6 2 2 6 2 2 6
50083 - 2 2 6 2 2 6 2 2 6 26 26 26
50084 - 54 54 54 38 38 38 18 18 18 10 10 10
50085 - 2 2 6 2 2 6 34 34 34 82 82 82
50086 - 38 38 38 14 14 14 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 0 0 0
50089 - 0 0 0 0 0 0 0 0 0 0 0 0
50090 - 0 0 0 0 0 0 0 0 0 0 0 0
50091 - 0 0 0 0 0 0 0 0 0 0 0 0
50092 - 0 0 0 0 0 0 0 0 0 0 0 0
50093 - 0 0 0 0 0 0 0 0 0 0 0 0
50094 - 0 0 0 0 0 1 0 0 1 0 0 0
50095 - 0 0 0 0 0 0 0 0 0 0 0 0
50096 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
50100 - 30 30 30 78 78 78 30 30 30 2 2 6
50101 - 2 2 6 2 2 6 2 2 6 2 2 6
50102 - 2 2 6 2 2 6 2 2 6 2 2 6
50103 - 2 2 6 2 2 6 2 2 6 10 10 10
50104 - 10 10 10 2 2 6 2 2 6 2 2 6
50105 - 2 2 6 2 2 6 2 2 6 78 78 78
50106 - 50 50 50 18 18 18 6 6 6 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 0 0 0
50109 - 0 0 0 0 0 0 0 0 0 0 0 0
50110 - 0 0 0 0 0 0 0 0 0 0 0 0
50111 - 0 0 0 0 0 0 0 0 0 0 0 0
50112 - 0 0 0 0 0 0 0 0 0 0 0 0
50113 - 0 0 0 0 0 0 0 0 0 0 0 0
50114 - 0 0 1 0 0 0 0 0 0 0 0 0
50115 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
50120 - 38 38 38 86 86 86 14 14 14 2 2 6
50121 - 2 2 6 2 2 6 2 2 6 2 2 6
50122 - 2 2 6 2 2 6 2 2 6 2 2 6
50123 - 2 2 6 2 2 6 2 2 6 2 2 6
50124 - 2 2 6 2 2 6 2 2 6 2 2 6
50125 - 2 2 6 2 2 6 2 2 6 54 54 54
50126 - 66 66 66 26 26 26 6 6 6 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 0 0 0
50129 - 0 0 0 0 0 0 0 0 0 0 0 0
50130 - 0 0 0 0 0 0 0 0 0 0 0 0
50131 - 0 0 0 0 0 0 0 0 0 0 0 0
50132 - 0 0 0 0 0 0 0 0 0 0 0 0
50133 - 0 0 0 0 0 0 0 0 0 0 0 0
50134 - 0 0 0 0 0 1 0 0 1 0 0 0
50135 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50140 - 42 42 42 82 82 82 2 2 6 2 2 6
50141 - 2 2 6 6 6 6 10 10 10 2 2 6
50142 - 2 2 6 2 2 6 2 2 6 2 2 6
50143 - 2 2 6 2 2 6 2 2 6 6 6 6
50144 - 14 14 14 10 10 10 2 2 6 2 2 6
50145 - 2 2 6 2 2 6 2 2 6 18 18 18
50146 - 82 82 82 34 34 34 10 10 10 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 0 0 0
50149 - 0 0 0 0 0 0 0 0 0 0 0 0
50150 - 0 0 0 0 0 0 0 0 0 0 0 0
50151 - 0 0 0 0 0 0 0 0 0 0 0 0
50152 - 0 0 0 0 0 0 0 0 0 0 0 0
50153 - 0 0 0 0 0 0 0 0 0 0 0 0
50154 - 0 0 1 0 0 0 0 0 0 0 0 0
50155 - 0 0 0 0 0 0 0 0 0 0 0 0
50156 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50160 - 46 46 46 86 86 86 2 2 6 2 2 6
50161 - 6 6 6 6 6 6 22 22 22 34 34 34
50162 - 6 6 6 2 2 6 2 2 6 2 2 6
50163 - 2 2 6 2 2 6 18 18 18 34 34 34
50164 - 10 10 10 50 50 50 22 22 22 2 2 6
50165 - 2 2 6 2 2 6 2 2 6 10 10 10
50166 - 86 86 86 42 42 42 14 14 14 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 0 0 0
50169 - 0 0 0 0 0 0 0 0 0 0 0 0
50170 - 0 0 0 0 0 0 0 0 0 0 0 0
50171 - 0 0 0 0 0 0 0 0 0 0 0 0
50172 - 0 0 0 0 0 0 0 0 0 0 0 0
50173 - 0 0 0 0 0 0 0 0 0 0 0 0
50174 - 0 0 1 0 0 1 0 0 1 0 0 0
50175 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50180 - 46 46 46 86 86 86 2 2 6 2 2 6
50181 - 38 38 38 116 116 116 94 94 94 22 22 22
50182 - 22 22 22 2 2 6 2 2 6 2 2 6
50183 - 14 14 14 86 86 86 138 138 138 162 162 162
50184 -154 154 154 38 38 38 26 26 26 6 6 6
50185 - 2 2 6 2 2 6 2 2 6 2 2 6
50186 - 86 86 86 46 46 46 14 14 14 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 0 0 0
50189 - 0 0 0 0 0 0 0 0 0 0 0 0
50190 - 0 0 0 0 0 0 0 0 0 0 0 0
50191 - 0 0 0 0 0 0 0 0 0 0 0 0
50192 - 0 0 0 0 0 0 0 0 0 0 0 0
50193 - 0 0 0 0 0 0 0 0 0 0 0 0
50194 - 0 0 0 0 0 0 0 0 0 0 0 0
50195 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50200 - 46 46 46 86 86 86 2 2 6 14 14 14
50201 -134 134 134 198 198 198 195 195 195 116 116 116
50202 - 10 10 10 2 2 6 2 2 6 6 6 6
50203 -101 98 89 187 187 187 210 210 210 218 218 218
50204 -214 214 214 134 134 134 14 14 14 6 6 6
50205 - 2 2 6 2 2 6 2 2 6 2 2 6
50206 - 86 86 86 50 50 50 18 18 18 6 6 6
50207 - 0 0 0 0 0 0 0 0 0 0 0 0
50208 - 0 0 0 0 0 0 0 0 0 0 0 0
50209 - 0 0 0 0 0 0 0 0 0 0 0 0
50210 - 0 0 0 0 0 0 0 0 0 0 0 0
50211 - 0 0 0 0 0 0 0 0 0 0 0 0
50212 - 0 0 0 0 0 0 0 0 0 0 0 0
50213 - 0 0 0 0 0 0 0 0 1 0 0 0
50214 - 0 0 1 0 0 1 0 0 1 0 0 0
50215 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50220 - 46 46 46 86 86 86 2 2 6 54 54 54
50221 -218 218 218 195 195 195 226 226 226 246 246 246
50222 - 58 58 58 2 2 6 2 2 6 30 30 30
50223 -210 210 210 253 253 253 174 174 174 123 123 123
50224 -221 221 221 234 234 234 74 74 74 2 2 6
50225 - 2 2 6 2 2 6 2 2 6 2 2 6
50226 - 70 70 70 58 58 58 22 22 22 6 6 6
50227 - 0 0 0 0 0 0 0 0 0 0 0 0
50228 - 0 0 0 0 0 0 0 0 0 0 0 0
50229 - 0 0 0 0 0 0 0 0 0 0 0 0
50230 - 0 0 0 0 0 0 0 0 0 0 0 0
50231 - 0 0 0 0 0 0 0 0 0 0 0 0
50232 - 0 0 0 0 0 0 0 0 0 0 0 0
50233 - 0 0 0 0 0 0 0 0 0 0 0 0
50234 - 0 0 0 0 0 0 0 0 0 0 0 0
50235 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50240 - 46 46 46 82 82 82 2 2 6 106 106 106
50241 -170 170 170 26 26 26 86 86 86 226 226 226
50242 -123 123 123 10 10 10 14 14 14 46 46 46
50243 -231 231 231 190 190 190 6 6 6 70 70 70
50244 - 90 90 90 238 238 238 158 158 158 2 2 6
50245 - 2 2 6 2 2 6 2 2 6 2 2 6
50246 - 70 70 70 58 58 58 22 22 22 6 6 6
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 0 0 0 0 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 0 0 0 0 0 0 0 0 1 0 0 0
50254 - 0 0 1 0 0 1 0 0 1 0 0 0
50255 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
50260 - 42 42 42 86 86 86 6 6 6 116 116 116
50261 -106 106 106 6 6 6 70 70 70 149 149 149
50262 -128 128 128 18 18 18 38 38 38 54 54 54
50263 -221 221 221 106 106 106 2 2 6 14 14 14
50264 - 46 46 46 190 190 190 198 198 198 2 2 6
50265 - 2 2 6 2 2 6 2 2 6 2 2 6
50266 - 74 74 74 62 62 62 22 22 22 6 6 6
50267 - 0 0 0 0 0 0 0 0 0 0 0 0
50268 - 0 0 0 0 0 0 0 0 0 0 0 0
50269 - 0 0 0 0 0 0 0 0 0 0 0 0
50270 - 0 0 0 0 0 0 0 0 0 0 0 0
50271 - 0 0 0 0 0 0 0 0 0 0 0 0
50272 - 0 0 0 0 0 0 0 0 0 0 0 0
50273 - 0 0 0 0 0 0 0 0 1 0 0 0
50274 - 0 0 1 0 0 0 0 0 1 0 0 0
50275 - 0 0 0 0 0 0 0 0 0 0 0 0
50276 - 0 0 0 0 0 0 0 0 0 0 0 0
50277 - 0 0 0 0 0 0 0 0 0 0 0 0
50278 - 0 0 0 0 0 0 0 0 0 0 0 0
50279 - 0 0 0 0 0 0 0 0 0 14 14 14
50280 - 42 42 42 94 94 94 14 14 14 101 101 101
50281 -128 128 128 2 2 6 18 18 18 116 116 116
50282 -118 98 46 121 92 8 121 92 8 98 78 10
50283 -162 162 162 106 106 106 2 2 6 2 2 6
50284 - 2 2 6 195 195 195 195 195 195 6 6 6
50285 - 2 2 6 2 2 6 2 2 6 2 2 6
50286 - 74 74 74 62 62 62 22 22 22 6 6 6
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 0 0 0
50289 - 0 0 0 0 0 0 0 0 0 0 0 0
50290 - 0 0 0 0 0 0 0 0 0 0 0 0
50291 - 0 0 0 0 0 0 0 0 0 0 0 0
50292 - 0 0 0 0 0 0 0 0 0 0 0 0
50293 - 0 0 0 0 0 0 0 0 1 0 0 1
50294 - 0 0 1 0 0 0 0 0 1 0 0 0
50295 - 0 0 0 0 0 0 0 0 0 0 0 0
50296 - 0 0 0 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 10 10 10
50300 - 38 38 38 90 90 90 14 14 14 58 58 58
50301 -210 210 210 26 26 26 54 38 6 154 114 10
50302 -226 170 11 236 186 11 225 175 15 184 144 12
50303 -215 174 15 175 146 61 37 26 9 2 2 6
50304 - 70 70 70 246 246 246 138 138 138 2 2 6
50305 - 2 2 6 2 2 6 2 2 6 2 2 6
50306 - 70 70 70 66 66 66 26 26 26 6 6 6
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 0 0 0
50309 - 0 0 0 0 0 0 0 0 0 0 0 0
50310 - 0 0 0 0 0 0 0 0 0 0 0 0
50311 - 0 0 0 0 0 0 0 0 0 0 0 0
50312 - 0 0 0 0 0 0 0 0 0 0 0 0
50313 - 0 0 0 0 0 0 0 0 0 0 0 0
50314 - 0 0 0 0 0 0 0 0 0 0 0 0
50315 - 0 0 0 0 0 0 0 0 0 0 0 0
50316 - 0 0 0 0 0 0 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 10 10 10
50320 - 38 38 38 86 86 86 14 14 14 10 10 10
50321 -195 195 195 188 164 115 192 133 9 225 175 15
50322 -239 182 13 234 190 10 232 195 16 232 200 30
50323 -245 207 45 241 208 19 232 195 16 184 144 12
50324 -218 194 134 211 206 186 42 42 42 2 2 6
50325 - 2 2 6 2 2 6 2 2 6 2 2 6
50326 - 50 50 50 74 74 74 30 30 30 6 6 6
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 0 0 0
50329 - 0 0 0 0 0 0 0 0 0 0 0 0
50330 - 0 0 0 0 0 0 0 0 0 0 0 0
50331 - 0 0 0 0 0 0 0 0 0 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 0 0 0
50333 - 0 0 0 0 0 0 0 0 0 0 0 0
50334 - 0 0 0 0 0 0 0 0 0 0 0 0
50335 - 0 0 0 0 0 0 0 0 0 0 0 0
50336 - 0 0 0 0 0 0 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 10 10 10
50340 - 34 34 34 86 86 86 14 14 14 2 2 6
50341 -121 87 25 192 133 9 219 162 10 239 182 13
50342 -236 186 11 232 195 16 241 208 19 244 214 54
50343 -246 218 60 246 218 38 246 215 20 241 208 19
50344 -241 208 19 226 184 13 121 87 25 2 2 6
50345 - 2 2 6 2 2 6 2 2 6 2 2 6
50346 - 50 50 50 82 82 82 34 34 34 10 10 10
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 0 0 0 0 0 0
50349 - 0 0 0 0 0 0 0 0 0 0 0 0
50350 - 0 0 0 0 0 0 0 0 0 0 0 0
50351 - 0 0 0 0 0 0 0 0 0 0 0 0
50352 - 0 0 0 0 0 0 0 0 0 0 0 0
50353 - 0 0 0 0 0 0 0 0 0 0 0 0
50354 - 0 0 0 0 0 0 0 0 0 0 0 0
50355 - 0 0 0 0 0 0 0 0 0 0 0 0
50356 - 0 0 0 0 0 0 0 0 0 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 10 10 10
50360 - 34 34 34 82 82 82 30 30 30 61 42 6
50361 -180 123 7 206 145 10 230 174 11 239 182 13
50362 -234 190 10 238 202 15 241 208 19 246 218 74
50363 -246 218 38 246 215 20 246 215 20 246 215 20
50364 -226 184 13 215 174 15 184 144 12 6 6 6
50365 - 2 2 6 2 2 6 2 2 6 2 2 6
50366 - 26 26 26 94 94 94 42 42 42 14 14 14
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 0 0 0 0 0 0
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 0 0 0 0
50371 - 0 0 0 0 0 0 0 0 0 0 0 0
50372 - 0 0 0 0 0 0 0 0 0 0 0 0
50373 - 0 0 0 0 0 0 0 0 0 0 0 0
50374 - 0 0 0 0 0 0 0 0 0 0 0 0
50375 - 0 0 0 0 0 0 0 0 0 0 0 0
50376 - 0 0 0 0 0 0 0 0 0 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 10 10 10
50380 - 30 30 30 78 78 78 50 50 50 104 69 6
50381 -192 133 9 216 158 10 236 178 12 236 186 11
50382 -232 195 16 241 208 19 244 214 54 245 215 43
50383 -246 215 20 246 215 20 241 208 19 198 155 10
50384 -200 144 11 216 158 10 156 118 10 2 2 6
50385 - 2 2 6 2 2 6 2 2 6 2 2 6
50386 - 6 6 6 90 90 90 54 54 54 18 18 18
50387 - 6 6 6 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 0 0 0 0 0 0 0 0 0
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 0 0 0 0 0 0 0 0 0 0
50393 - 0 0 0 0 0 0 0 0 0 0 0 0
50394 - 0 0 0 0 0 0 0 0 0 0 0 0
50395 - 0 0 0 0 0 0 0 0 0 0 0 0
50396 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
50400 - 30 30 30 78 78 78 46 46 46 22 22 22
50401 -137 92 6 210 162 10 239 182 13 238 190 10
50402 -238 202 15 241 208 19 246 215 20 246 215 20
50403 -241 208 19 203 166 17 185 133 11 210 150 10
50404 -216 158 10 210 150 10 102 78 10 2 2 6
50405 - 6 6 6 54 54 54 14 14 14 2 2 6
50406 - 2 2 6 62 62 62 74 74 74 30 30 30
50407 - 10 10 10 0 0 0 0 0 0 0 0 0
50408 - 0 0 0 0 0 0 0 0 0 0 0 0
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 0 0 0 0
50411 - 0 0 0 0 0 0 0 0 0 0 0 0
50412 - 0 0 0 0 0 0 0 0 0 0 0 0
50413 - 0 0 0 0 0 0 0 0 0 0 0 0
50414 - 0 0 0 0 0 0 0 0 0 0 0 0
50415 - 0 0 0 0 0 0 0 0 0 0 0 0
50416 - 0 0 0 0 0 0 0 0 0 0 0 0
50417 - 0 0 0 0 0 0 0 0 0 0 0 0
50418 - 0 0 0 0 0 0 0 0 0 0 0 0
50419 - 0 0 0 0 0 0 0 0 0 10 10 10
50420 - 34 34 34 78 78 78 50 50 50 6 6 6
50421 - 94 70 30 139 102 15 190 146 13 226 184 13
50422 -232 200 30 232 195 16 215 174 15 190 146 13
50423 -168 122 10 192 133 9 210 150 10 213 154 11
50424 -202 150 34 182 157 106 101 98 89 2 2 6
50425 - 2 2 6 78 78 78 116 116 116 58 58 58
50426 - 2 2 6 22 22 22 90 90 90 46 46 46
50427 - 18 18 18 6 6 6 0 0 0 0 0 0
50428 - 0 0 0 0 0 0 0 0 0 0 0 0
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 0 0 0 0
50431 - 0 0 0 0 0 0 0 0 0 0 0 0
50432 - 0 0 0 0 0 0 0 0 0 0 0 0
50433 - 0 0 0 0 0 0 0 0 0 0 0 0
50434 - 0 0 0 0 0 0 0 0 0 0 0 0
50435 - 0 0 0 0 0 0 0 0 0 0 0 0
50436 - 0 0 0 0 0 0 0 0 0 0 0 0
50437 - 0 0 0 0 0 0 0 0 0 0 0 0
50438 - 0 0 0 0 0 0 0 0 0 0 0 0
50439 - 0 0 0 0 0 0 0 0 0 10 10 10
50440 - 38 38 38 86 86 86 50 50 50 6 6 6
50441 -128 128 128 174 154 114 156 107 11 168 122 10
50442 -198 155 10 184 144 12 197 138 11 200 144 11
50443 -206 145 10 206 145 10 197 138 11 188 164 115
50444 -195 195 195 198 198 198 174 174 174 14 14 14
50445 - 2 2 6 22 22 22 116 116 116 116 116 116
50446 - 22 22 22 2 2 6 74 74 74 70 70 70
50447 - 30 30 30 10 10 10 0 0 0 0 0 0
50448 - 0 0 0 0 0 0 0 0 0 0 0 0
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 0 0 0 0
50451 - 0 0 0 0 0 0 0 0 0 0 0 0
50452 - 0 0 0 0 0 0 0 0 0 0 0 0
50453 - 0 0 0 0 0 0 0 0 0 0 0 0
50454 - 0 0 0 0 0 0 0 0 0 0 0 0
50455 - 0 0 0 0 0 0 0 0 0 0 0 0
50456 - 0 0 0 0 0 0 0 0 0 0 0 0
50457 - 0 0 0 0 0 0 0 0 0 0 0 0
50458 - 0 0 0 0 0 0 0 0 0 0 0 0
50459 - 0 0 0 0 0 0 6 6 6 18 18 18
50460 - 50 50 50 101 101 101 26 26 26 10 10 10
50461 -138 138 138 190 190 190 174 154 114 156 107 11
50462 -197 138 11 200 144 11 197 138 11 192 133 9
50463 -180 123 7 190 142 34 190 178 144 187 187 187
50464 -202 202 202 221 221 221 214 214 214 66 66 66
50465 - 2 2 6 2 2 6 50 50 50 62 62 62
50466 - 6 6 6 2 2 6 10 10 10 90 90 90
50467 - 50 50 50 18 18 18 6 6 6 0 0 0
50468 - 0 0 0 0 0 0 0 0 0 0 0 0
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 0 0 0 0 0 0 0 0 0 0 0 0
50472 - 0 0 0 0 0 0 0 0 0 0 0 0
50473 - 0 0 0 0 0 0 0 0 0 0 0 0
50474 - 0 0 0 0 0 0 0 0 0 0 0 0
50475 - 0 0 0 0 0 0 0 0 0 0 0 0
50476 - 0 0 0 0 0 0 0 0 0 0 0 0
50477 - 0 0 0 0 0 0 0 0 0 0 0 0
50478 - 0 0 0 0 0 0 0 0 0 0 0 0
50479 - 0 0 0 0 0 0 10 10 10 34 34 34
50480 - 74 74 74 74 74 74 2 2 6 6 6 6
50481 -144 144 144 198 198 198 190 190 190 178 166 146
50482 -154 121 60 156 107 11 156 107 11 168 124 44
50483 -174 154 114 187 187 187 190 190 190 210 210 210
50484 -246 246 246 253 253 253 253 253 253 182 182 182
50485 - 6 6 6 2 2 6 2 2 6 2 2 6
50486 - 2 2 6 2 2 6 2 2 6 62 62 62
50487 - 74 74 74 34 34 34 14 14 14 0 0 0
50488 - 0 0 0 0 0 0 0 0 0 0 0 0
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 0 0 0 0 0 0 0 0 0 0 0 0
50492 - 0 0 0 0 0 0 0 0 0 0 0 0
50493 - 0 0 0 0 0 0 0 0 0 0 0 0
50494 - 0 0 0 0 0 0 0 0 0 0 0 0
50495 - 0 0 0 0 0 0 0 0 0 0 0 0
50496 - 0 0 0 0 0 0 0 0 0 0 0 0
50497 - 0 0 0 0 0 0 0 0 0 0 0 0
50498 - 0 0 0 0 0 0 0 0 0 0 0 0
50499 - 0 0 0 10 10 10 22 22 22 54 54 54
50500 - 94 94 94 18 18 18 2 2 6 46 46 46
50501 -234 234 234 221 221 221 190 190 190 190 190 190
50502 -190 190 190 187 187 187 187 187 187 190 190 190
50503 -190 190 190 195 195 195 214 214 214 242 242 242
50504 -253 253 253 253 253 253 253 253 253 253 253 253
50505 - 82 82 82 2 2 6 2 2 6 2 2 6
50506 - 2 2 6 2 2 6 2 2 6 14 14 14
50507 - 86 86 86 54 54 54 22 22 22 6 6 6
50508 - 0 0 0 0 0 0 0 0 0 0 0 0
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 0 0 0
50511 - 0 0 0 0 0 0 0 0 0 0 0 0
50512 - 0 0 0 0 0 0 0 0 0 0 0 0
50513 - 0 0 0 0 0 0 0 0 0 0 0 0
50514 - 0 0 0 0 0 0 0 0 0 0 0 0
50515 - 0 0 0 0 0 0 0 0 0 0 0 0
50516 - 0 0 0 0 0 0 0 0 0 0 0 0
50517 - 0 0 0 0 0 0 0 0 0 0 0 0
50518 - 0 0 0 0 0 0 0 0 0 0 0 0
50519 - 6 6 6 18 18 18 46 46 46 90 90 90
50520 - 46 46 46 18 18 18 6 6 6 182 182 182
50521 -253 253 253 246 246 246 206 206 206 190 190 190
50522 -190 190 190 190 190 190 190 190 190 190 190 190
50523 -206 206 206 231 231 231 250 250 250 253 253 253
50524 -253 253 253 253 253 253 253 253 253 253 253 253
50525 -202 202 202 14 14 14 2 2 6 2 2 6
50526 - 2 2 6 2 2 6 2 2 6 2 2 6
50527 - 42 42 42 86 86 86 42 42 42 18 18 18
50528 - 6 6 6 0 0 0 0 0 0 0 0 0
50529 - 0 0 0 0 0 0 0 0 0 0 0 0
50530 - 0 0 0 0 0 0 0 0 0 0 0 0
50531 - 0 0 0 0 0 0 0 0 0 0 0 0
50532 - 0 0 0 0 0 0 0 0 0 0 0 0
50533 - 0 0 0 0 0 0 0 0 0 0 0 0
50534 - 0 0 0 0 0 0 0 0 0 0 0 0
50535 - 0 0 0 0 0 0 0 0 0 0 0 0
50536 - 0 0 0 0 0 0 0 0 0 0 0 0
50537 - 0 0 0 0 0 0 0 0 0 0 0 0
50538 - 0 0 0 0 0 0 0 0 0 6 6 6
50539 - 14 14 14 38 38 38 74 74 74 66 66 66
50540 - 2 2 6 6 6 6 90 90 90 250 250 250
50541 -253 253 253 253 253 253 238 238 238 198 198 198
50542 -190 190 190 190 190 190 195 195 195 221 221 221
50543 -246 246 246 253 253 253 253 253 253 253 253 253
50544 -253 253 253 253 253 253 253 253 253 253 253 253
50545 -253 253 253 82 82 82 2 2 6 2 2 6
50546 - 2 2 6 2 2 6 2 2 6 2 2 6
50547 - 2 2 6 78 78 78 70 70 70 34 34 34
50548 - 14 14 14 6 6 6 0 0 0 0 0 0
50549 - 0 0 0 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 0 0 0
50551 - 0 0 0 0 0 0 0 0 0 0 0 0
50552 - 0 0 0 0 0 0 0 0 0 0 0 0
50553 - 0 0 0 0 0 0 0 0 0 0 0 0
50554 - 0 0 0 0 0 0 0 0 0 0 0 0
50555 - 0 0 0 0 0 0 0 0 0 0 0 0
50556 - 0 0 0 0 0 0 0 0 0 0 0 0
50557 - 0 0 0 0 0 0 0 0 0 0 0 0
50558 - 0 0 0 0 0 0 0 0 0 14 14 14
50559 - 34 34 34 66 66 66 78 78 78 6 6 6
50560 - 2 2 6 18 18 18 218 218 218 253 253 253
50561 -253 253 253 253 253 253 253 253 253 246 246 246
50562 -226 226 226 231 231 231 246 246 246 253 253 253
50563 -253 253 253 253 253 253 253 253 253 253 253 253
50564 -253 253 253 253 253 253 253 253 253 253 253 253
50565 -253 253 253 178 178 178 2 2 6 2 2 6
50566 - 2 2 6 2 2 6 2 2 6 2 2 6
50567 - 2 2 6 18 18 18 90 90 90 62 62 62
50568 - 30 30 30 10 10 10 0 0 0 0 0 0
50569 - 0 0 0 0 0 0 0 0 0 0 0 0
50570 - 0 0 0 0 0 0 0 0 0 0 0 0
50571 - 0 0 0 0 0 0 0 0 0 0 0 0
50572 - 0 0 0 0 0 0 0 0 0 0 0 0
50573 - 0 0 0 0 0 0 0 0 0 0 0 0
50574 - 0 0 0 0 0 0 0 0 0 0 0 0
50575 - 0 0 0 0 0 0 0 0 0 0 0 0
50576 - 0 0 0 0 0 0 0 0 0 0 0 0
50577 - 0 0 0 0 0 0 0 0 0 0 0 0
50578 - 0 0 0 0 0 0 10 10 10 26 26 26
50579 - 58 58 58 90 90 90 18 18 18 2 2 6
50580 - 2 2 6 110 110 110 253 253 253 253 253 253
50581 -253 253 253 253 253 253 253 253 253 253 253 253
50582 -250 250 250 253 253 253 253 253 253 253 253 253
50583 -253 253 253 253 253 253 253 253 253 253 253 253
50584 -253 253 253 253 253 253 253 253 253 253 253 253
50585 -253 253 253 231 231 231 18 18 18 2 2 6
50586 - 2 2 6 2 2 6 2 2 6 2 2 6
50587 - 2 2 6 2 2 6 18 18 18 94 94 94
50588 - 54 54 54 26 26 26 10 10 10 0 0 0
50589 - 0 0 0 0 0 0 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 0 0 0
50591 - 0 0 0 0 0 0 0 0 0 0 0 0
50592 - 0 0 0 0 0 0 0 0 0 0 0 0
50593 - 0 0 0 0 0 0 0 0 0 0 0 0
50594 - 0 0 0 0 0 0 0 0 0 0 0 0
50595 - 0 0 0 0 0 0 0 0 0 0 0 0
50596 - 0 0 0 0 0 0 0 0 0 0 0 0
50597 - 0 0 0 0 0 0 0 0 0 0 0 0
50598 - 0 0 0 6 6 6 22 22 22 50 50 50
50599 - 90 90 90 26 26 26 2 2 6 2 2 6
50600 - 14 14 14 195 195 195 250 250 250 253 253 253
50601 -253 253 253 253 253 253 253 253 253 253 253 253
50602 -253 253 253 253 253 253 253 253 253 253 253 253
50603 -253 253 253 253 253 253 253 253 253 253 253 253
50604 -253 253 253 253 253 253 253 253 253 253 253 253
50605 -250 250 250 242 242 242 54 54 54 2 2 6
50606 - 2 2 6 2 2 6 2 2 6 2 2 6
50607 - 2 2 6 2 2 6 2 2 6 38 38 38
50608 - 86 86 86 50 50 50 22 22 22 6 6 6
50609 - 0 0 0 0 0 0 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 0 0 0
50611 - 0 0 0 0 0 0 0 0 0 0 0 0
50612 - 0 0 0 0 0 0 0 0 0 0 0 0
50613 - 0 0 0 0 0 0 0 0 0 0 0 0
50614 - 0 0 0 0 0 0 0 0 0 0 0 0
50615 - 0 0 0 0 0 0 0 0 0 0 0 0
50616 - 0 0 0 0 0 0 0 0 0 0 0 0
50617 - 0 0 0 0 0 0 0 0 0 0 0 0
50618 - 6 6 6 14 14 14 38 38 38 82 82 82
50619 - 34 34 34 2 2 6 2 2 6 2 2 6
50620 - 42 42 42 195 195 195 246 246 246 253 253 253
50621 -253 253 253 253 253 253 253 253 253 250 250 250
50622 -242 242 242 242 242 242 250 250 250 253 253 253
50623 -253 253 253 253 253 253 253 253 253 253 253 253
50624 -253 253 253 250 250 250 246 246 246 238 238 238
50625 -226 226 226 231 231 231 101 101 101 6 6 6
50626 - 2 2 6 2 2 6 2 2 6 2 2 6
50627 - 2 2 6 2 2 6 2 2 6 2 2 6
50628 - 38 38 38 82 82 82 42 42 42 14 14 14
50629 - 6 6 6 0 0 0 0 0 0 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 0 0 0
50631 - 0 0 0 0 0 0 0 0 0 0 0 0
50632 - 0 0 0 0 0 0 0 0 0 0 0 0
50633 - 0 0 0 0 0 0 0 0 0 0 0 0
50634 - 0 0 0 0 0 0 0 0 0 0 0 0
50635 - 0 0 0 0 0 0 0 0 0 0 0 0
50636 - 0 0 0 0 0 0 0 0 0 0 0 0
50637 - 0 0 0 0 0 0 0 0 0 0 0 0
50638 - 10 10 10 26 26 26 62 62 62 66 66 66
50639 - 2 2 6 2 2 6 2 2 6 6 6 6
50640 - 70 70 70 170 170 170 206 206 206 234 234 234
50641 -246 246 246 250 250 250 250 250 250 238 238 238
50642 -226 226 226 231 231 231 238 238 238 250 250 250
50643 -250 250 250 250 250 250 246 246 246 231 231 231
50644 -214 214 214 206 206 206 202 202 202 202 202 202
50645 -198 198 198 202 202 202 182 182 182 18 18 18
50646 - 2 2 6 2 2 6 2 2 6 2 2 6
50647 - 2 2 6 2 2 6 2 2 6 2 2 6
50648 - 2 2 6 62 62 62 66 66 66 30 30 30
50649 - 10 10 10 0 0 0 0 0 0 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 0 0 0
50651 - 0 0 0 0 0 0 0 0 0 0 0 0
50652 - 0 0 0 0 0 0 0 0 0 0 0 0
50653 - 0 0 0 0 0 0 0 0 0 0 0 0
50654 - 0 0 0 0 0 0 0 0 0 0 0 0
50655 - 0 0 0 0 0 0 0 0 0 0 0 0
50656 - 0 0 0 0 0 0 0 0 0 0 0 0
50657 - 0 0 0 0 0 0 0 0 0 0 0 0
50658 - 14 14 14 42 42 42 82 82 82 18 18 18
50659 - 2 2 6 2 2 6 2 2 6 10 10 10
50660 - 94 94 94 182 182 182 218 218 218 242 242 242
50661 -250 250 250 253 253 253 253 253 253 250 250 250
50662 -234 234 234 253 253 253 253 253 253 253 253 253
50663 -253 253 253 253 253 253 253 253 253 246 246 246
50664 -238 238 238 226 226 226 210 210 210 202 202 202
50665 -195 195 195 195 195 195 210 210 210 158 158 158
50666 - 6 6 6 14 14 14 50 50 50 14 14 14
50667 - 2 2 6 2 2 6 2 2 6 2 2 6
50668 - 2 2 6 6 6 6 86 86 86 46 46 46
50669 - 18 18 18 6 6 6 0 0 0 0 0 0
50670 - 0 0 0 0 0 0 0 0 0 0 0 0
50671 - 0 0 0 0 0 0 0 0 0 0 0 0
50672 - 0 0 0 0 0 0 0 0 0 0 0 0
50673 - 0 0 0 0 0 0 0 0 0 0 0 0
50674 - 0 0 0 0 0 0 0 0 0 0 0 0
50675 - 0 0 0 0 0 0 0 0 0 0 0 0
50676 - 0 0 0 0 0 0 0 0 0 0 0 0
50677 - 0 0 0 0 0 0 0 0 0 6 6 6
50678 - 22 22 22 54 54 54 70 70 70 2 2 6
50679 - 2 2 6 10 10 10 2 2 6 22 22 22
50680 -166 166 166 231 231 231 250 250 250 253 253 253
50681 -253 253 253 253 253 253 253 253 253 250 250 250
50682 -242 242 242 253 253 253 253 253 253 253 253 253
50683 -253 253 253 253 253 253 253 253 253 253 253 253
50684 -253 253 253 253 253 253 253 253 253 246 246 246
50685 -231 231 231 206 206 206 198 198 198 226 226 226
50686 - 94 94 94 2 2 6 6 6 6 38 38 38
50687 - 30 30 30 2 2 6 2 2 6 2 2 6
50688 - 2 2 6 2 2 6 62 62 62 66 66 66
50689 - 26 26 26 10 10 10 0 0 0 0 0 0
50690 - 0 0 0 0 0 0 0 0 0 0 0 0
50691 - 0 0 0 0 0 0 0 0 0 0 0 0
50692 - 0 0 0 0 0 0 0 0 0 0 0 0
50693 - 0 0 0 0 0 0 0 0 0 0 0 0
50694 - 0 0 0 0 0 0 0 0 0 0 0 0
50695 - 0 0 0 0 0 0 0 0 0 0 0 0
50696 - 0 0 0 0 0 0 0 0 0 0 0 0
50697 - 0 0 0 0 0 0 0 0 0 10 10 10
50698 - 30 30 30 74 74 74 50 50 50 2 2 6
50699 - 26 26 26 26 26 26 2 2 6 106 106 106
50700 -238 238 238 253 253 253 253 253 253 253 253 253
50701 -253 253 253 253 253 253 253 253 253 253 253 253
50702 -253 253 253 253 253 253 253 253 253 253 253 253
50703 -253 253 253 253 253 253 253 253 253 253 253 253
50704 -253 253 253 253 253 253 253 253 253 253 253 253
50705 -253 253 253 246 246 246 218 218 218 202 202 202
50706 -210 210 210 14 14 14 2 2 6 2 2 6
50707 - 30 30 30 22 22 22 2 2 6 2 2 6
50708 - 2 2 6 2 2 6 18 18 18 86 86 86
50709 - 42 42 42 14 14 14 0 0 0 0 0 0
50710 - 0 0 0 0 0 0 0 0 0 0 0 0
50711 - 0 0 0 0 0 0 0 0 0 0 0 0
50712 - 0 0 0 0 0 0 0 0 0 0 0 0
50713 - 0 0 0 0 0 0 0 0 0 0 0 0
50714 - 0 0 0 0 0 0 0 0 0 0 0 0
50715 - 0 0 0 0 0 0 0 0 0 0 0 0
50716 - 0 0 0 0 0 0 0 0 0 0 0 0
50717 - 0 0 0 0 0 0 0 0 0 14 14 14
50718 - 42 42 42 90 90 90 22 22 22 2 2 6
50719 - 42 42 42 2 2 6 18 18 18 218 218 218
50720 -253 253 253 253 253 253 253 253 253 253 253 253
50721 -253 253 253 253 253 253 253 253 253 253 253 253
50722 -253 253 253 253 253 253 253 253 253 253 253 253
50723 -253 253 253 253 253 253 253 253 253 253 253 253
50724 -253 253 253 253 253 253 253 253 253 253 253 253
50725 -253 253 253 253 253 253 250 250 250 221 221 221
50726 -218 218 218 101 101 101 2 2 6 14 14 14
50727 - 18 18 18 38 38 38 10 10 10 2 2 6
50728 - 2 2 6 2 2 6 2 2 6 78 78 78
50729 - 58 58 58 22 22 22 6 6 6 0 0 0
50730 - 0 0 0 0 0 0 0 0 0 0 0 0
50731 - 0 0 0 0 0 0 0 0 0 0 0 0
50732 - 0 0 0 0 0 0 0 0 0 0 0 0
50733 - 0 0 0 0 0 0 0 0 0 0 0 0
50734 - 0 0 0 0 0 0 0 0 0 0 0 0
50735 - 0 0 0 0 0 0 0 0 0 0 0 0
50736 - 0 0 0 0 0 0 0 0 0 0 0 0
50737 - 0 0 0 0 0 0 6 6 6 18 18 18
50738 - 54 54 54 82 82 82 2 2 6 26 26 26
50739 - 22 22 22 2 2 6 123 123 123 253 253 253
50740 -253 253 253 253 253 253 253 253 253 253 253 253
50741 -253 253 253 253 253 253 253 253 253 253 253 253
50742 -253 253 253 253 253 253 253 253 253 253 253 253
50743 -253 253 253 253 253 253 253 253 253 253 253 253
50744 -253 253 253 253 253 253 253 253 253 253 253 253
50745 -253 253 253 253 253 253 253 253 253 250 250 250
50746 -238 238 238 198 198 198 6 6 6 38 38 38
50747 - 58 58 58 26 26 26 38 38 38 2 2 6
50748 - 2 2 6 2 2 6 2 2 6 46 46 46
50749 - 78 78 78 30 30 30 10 10 10 0 0 0
50750 - 0 0 0 0 0 0 0 0 0 0 0 0
50751 - 0 0 0 0 0 0 0 0 0 0 0 0
50752 - 0 0 0 0 0 0 0 0 0 0 0 0
50753 - 0 0 0 0 0 0 0 0 0 0 0 0
50754 - 0 0 0 0 0 0 0 0 0 0 0 0
50755 - 0 0 0 0 0 0 0 0 0 0 0 0
50756 - 0 0 0 0 0 0 0 0 0 0 0 0
50757 - 0 0 0 0 0 0 10 10 10 30 30 30
50758 - 74 74 74 58 58 58 2 2 6 42 42 42
50759 - 2 2 6 22 22 22 231 231 231 253 253 253
50760 -253 253 253 253 253 253 253 253 253 253 253 253
50761 -253 253 253 253 253 253 253 253 253 250 250 250
50762 -253 253 253 253 253 253 253 253 253 253 253 253
50763 -253 253 253 253 253 253 253 253 253 253 253 253
50764 -253 253 253 253 253 253 253 253 253 253 253 253
50765 -253 253 253 253 253 253 253 253 253 253 253 253
50766 -253 253 253 246 246 246 46 46 46 38 38 38
50767 - 42 42 42 14 14 14 38 38 38 14 14 14
50768 - 2 2 6 2 2 6 2 2 6 6 6 6
50769 - 86 86 86 46 46 46 14 14 14 0 0 0
50770 - 0 0 0 0 0 0 0 0 0 0 0 0
50771 - 0 0 0 0 0 0 0 0 0 0 0 0
50772 - 0 0 0 0 0 0 0 0 0 0 0 0
50773 - 0 0 0 0 0 0 0 0 0 0 0 0
50774 - 0 0 0 0 0 0 0 0 0 0 0 0
50775 - 0 0 0 0 0 0 0 0 0 0 0 0
50776 - 0 0 0 0 0 0 0 0 0 0 0 0
50777 - 0 0 0 6 6 6 14 14 14 42 42 42
50778 - 90 90 90 18 18 18 18 18 18 26 26 26
50779 - 2 2 6 116 116 116 253 253 253 253 253 253
50780 -253 253 253 253 253 253 253 253 253 253 253 253
50781 -253 253 253 253 253 253 250 250 250 238 238 238
50782 -253 253 253 253 253 253 253 253 253 253 253 253
50783 -253 253 253 253 253 253 253 253 253 253 253 253
50784 -253 253 253 253 253 253 253 253 253 253 253 253
50785 -253 253 253 253 253 253 253 253 253 253 253 253
50786 -253 253 253 253 253 253 94 94 94 6 6 6
50787 - 2 2 6 2 2 6 10 10 10 34 34 34
50788 - 2 2 6 2 2 6 2 2 6 2 2 6
50789 - 74 74 74 58 58 58 22 22 22 6 6 6
50790 - 0 0 0 0 0 0 0 0 0 0 0 0
50791 - 0 0 0 0 0 0 0 0 0 0 0 0
50792 - 0 0 0 0 0 0 0 0 0 0 0 0
50793 - 0 0 0 0 0 0 0 0 0 0 0 0
50794 - 0 0 0 0 0 0 0 0 0 0 0 0
50795 - 0 0 0 0 0 0 0 0 0 0 0 0
50796 - 0 0 0 0 0 0 0 0 0 0 0 0
50797 - 0 0 0 10 10 10 26 26 26 66 66 66
50798 - 82 82 82 2 2 6 38 38 38 6 6 6
50799 - 14 14 14 210 210 210 253 253 253 253 253 253
50800 -253 253 253 253 253 253 253 253 253 253 253 253
50801 -253 253 253 253 253 253 246 246 246 242 242 242
50802 -253 253 253 253 253 253 253 253 253 253 253 253
50803 -253 253 253 253 253 253 253 253 253 253 253 253
50804 -253 253 253 253 253 253 253 253 253 253 253 253
50805 -253 253 253 253 253 253 253 253 253 253 253 253
50806 -253 253 253 253 253 253 144 144 144 2 2 6
50807 - 2 2 6 2 2 6 2 2 6 46 46 46
50808 - 2 2 6 2 2 6 2 2 6 2 2 6
50809 - 42 42 42 74 74 74 30 30 30 10 10 10
50810 - 0 0 0 0 0 0 0 0 0 0 0 0
50811 - 0 0 0 0 0 0 0 0 0 0 0 0
50812 - 0 0 0 0 0 0 0 0 0 0 0 0
50813 - 0 0 0 0 0 0 0 0 0 0 0 0
50814 - 0 0 0 0 0 0 0 0 0 0 0 0
50815 - 0 0 0 0 0 0 0 0 0 0 0 0
50816 - 0 0 0 0 0 0 0 0 0 0 0 0
50817 - 6 6 6 14 14 14 42 42 42 90 90 90
50818 - 26 26 26 6 6 6 42 42 42 2 2 6
50819 - 74 74 74 250 250 250 253 253 253 253 253 253
50820 -253 253 253 253 253 253 253 253 253 253 253 253
50821 -253 253 253 253 253 253 242 242 242 242 242 242
50822 -253 253 253 253 253 253 253 253 253 253 253 253
50823 -253 253 253 253 253 253 253 253 253 253 253 253
50824 -253 253 253 253 253 253 253 253 253 253 253 253
50825 -253 253 253 253 253 253 253 253 253 253 253 253
50826 -253 253 253 253 253 253 182 182 182 2 2 6
50827 - 2 2 6 2 2 6 2 2 6 46 46 46
50828 - 2 2 6 2 2 6 2 2 6 2 2 6
50829 - 10 10 10 86 86 86 38 38 38 10 10 10
50830 - 0 0 0 0 0 0 0 0 0 0 0 0
50831 - 0 0 0 0 0 0 0 0 0 0 0 0
50832 - 0 0 0 0 0 0 0 0 0 0 0 0
50833 - 0 0 0 0 0 0 0 0 0 0 0 0
50834 - 0 0 0 0 0 0 0 0 0 0 0 0
50835 - 0 0 0 0 0 0 0 0 0 0 0 0
50836 - 0 0 0 0 0 0 0 0 0 0 0 0
50837 - 10 10 10 26 26 26 66 66 66 82 82 82
50838 - 2 2 6 22 22 22 18 18 18 2 2 6
50839 -149 149 149 253 253 253 253 253 253 253 253 253
50840 -253 253 253 253 253 253 253 253 253 253 253 253
50841 -253 253 253 253 253 253 234 234 234 242 242 242
50842 -253 253 253 253 253 253 253 253 253 253 253 253
50843 -253 253 253 253 253 253 253 253 253 253 253 253
50844 -253 253 253 253 253 253 253 253 253 253 253 253
50845 -253 253 253 253 253 253 253 253 253 253 253 253
50846 -253 253 253 253 253 253 206 206 206 2 2 6
50847 - 2 2 6 2 2 6 2 2 6 38 38 38
50848 - 2 2 6 2 2 6 2 2 6 2 2 6
50849 - 6 6 6 86 86 86 46 46 46 14 14 14
50850 - 0 0 0 0 0 0 0 0 0 0 0 0
50851 - 0 0 0 0 0 0 0 0 0 0 0 0
50852 - 0 0 0 0 0 0 0 0 0 0 0 0
50853 - 0 0 0 0 0 0 0 0 0 0 0 0
50854 - 0 0 0 0 0 0 0 0 0 0 0 0
50855 - 0 0 0 0 0 0 0 0 0 0 0 0
50856 - 0 0 0 0 0 0 0 0 0 6 6 6
50857 - 18 18 18 46 46 46 86 86 86 18 18 18
50858 - 2 2 6 34 34 34 10 10 10 6 6 6
50859 -210 210 210 253 253 253 253 253 253 253 253 253
50860 -253 253 253 253 253 253 253 253 253 253 253 253
50861 -253 253 253 253 253 253 234 234 234 242 242 242
50862 -253 253 253 253 253 253 253 253 253 253 253 253
50863 -253 253 253 253 253 253 253 253 253 253 253 253
50864 -253 253 253 253 253 253 253 253 253 253 253 253
50865 -253 253 253 253 253 253 253 253 253 253 253 253
50866 -253 253 253 253 253 253 221 221 221 6 6 6
50867 - 2 2 6 2 2 6 6 6 6 30 30 30
50868 - 2 2 6 2 2 6 2 2 6 2 2 6
50869 - 2 2 6 82 82 82 54 54 54 18 18 18
50870 - 6 6 6 0 0 0 0 0 0 0 0 0
50871 - 0 0 0 0 0 0 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 0 0 0 0 0 0 0 0 0
50874 - 0 0 0 0 0 0 0 0 0 0 0 0
50875 - 0 0 0 0 0 0 0 0 0 0 0 0
50876 - 0 0 0 0 0 0 0 0 0 10 10 10
50877 - 26 26 26 66 66 66 62 62 62 2 2 6
50878 - 2 2 6 38 38 38 10 10 10 26 26 26
50879 -238 238 238 253 253 253 253 253 253 253 253 253
50880 -253 253 253 253 253 253 253 253 253 253 253 253
50881 -253 253 253 253 253 253 231 231 231 238 238 238
50882 -253 253 253 253 253 253 253 253 253 253 253 253
50883 -253 253 253 253 253 253 253 253 253 253 253 253
50884 -253 253 253 253 253 253 253 253 253 253 253 253
50885 -253 253 253 253 253 253 253 253 253 253 253 253
50886 -253 253 253 253 253 253 231 231 231 6 6 6
50887 - 2 2 6 2 2 6 10 10 10 30 30 30
50888 - 2 2 6 2 2 6 2 2 6 2 2 6
50889 - 2 2 6 66 66 66 58 58 58 22 22 22
50890 - 6 6 6 0 0 0 0 0 0 0 0 0
50891 - 0 0 0 0 0 0 0 0 0 0 0 0
50892 - 0 0 0 0 0 0 0 0 0 0 0 0
50893 - 0 0 0 0 0 0 0 0 0 0 0 0
50894 - 0 0 0 0 0 0 0 0 0 0 0 0
50895 - 0 0 0 0 0 0 0 0 0 0 0 0
50896 - 0 0 0 0 0 0 0 0 0 10 10 10
50897 - 38 38 38 78 78 78 6 6 6 2 2 6
50898 - 2 2 6 46 46 46 14 14 14 42 42 42
50899 -246 246 246 253 253 253 253 253 253 253 253 253
50900 -253 253 253 253 253 253 253 253 253 253 253 253
50901 -253 253 253 253 253 253 231 231 231 242 242 242
50902 -253 253 253 253 253 253 253 253 253 253 253 253
50903 -253 253 253 253 253 253 253 253 253 253 253 253
50904 -253 253 253 253 253 253 253 253 253 253 253 253
50905 -253 253 253 253 253 253 253 253 253 253 253 253
50906 -253 253 253 253 253 253 234 234 234 10 10 10
50907 - 2 2 6 2 2 6 22 22 22 14 14 14
50908 - 2 2 6 2 2 6 2 2 6 2 2 6
50909 - 2 2 6 66 66 66 62 62 62 22 22 22
50910 - 6 6 6 0 0 0 0 0 0 0 0 0
50911 - 0 0 0 0 0 0 0 0 0 0 0 0
50912 - 0 0 0 0 0 0 0 0 0 0 0 0
50913 - 0 0 0 0 0 0 0 0 0 0 0 0
50914 - 0 0 0 0 0 0 0 0 0 0 0 0
50915 - 0 0 0 0 0 0 0 0 0 0 0 0
50916 - 0 0 0 0 0 0 6 6 6 18 18 18
50917 - 50 50 50 74 74 74 2 2 6 2 2 6
50918 - 14 14 14 70 70 70 34 34 34 62 62 62
50919 -250 250 250 253 253 253 253 253 253 253 253 253
50920 -253 253 253 253 253 253 253 253 253 253 253 253
50921 -253 253 253 253 253 253 231 231 231 246 246 246
50922 -253 253 253 253 253 253 253 253 253 253 253 253
50923 -253 253 253 253 253 253 253 253 253 253 253 253
50924 -253 253 253 253 253 253 253 253 253 253 253 253
50925 -253 253 253 253 253 253 253 253 253 253 253 253
50926 -253 253 253 253 253 253 234 234 234 14 14 14
50927 - 2 2 6 2 2 6 30 30 30 2 2 6
50928 - 2 2 6 2 2 6 2 2 6 2 2 6
50929 - 2 2 6 66 66 66 62 62 62 22 22 22
50930 - 6 6 6 0 0 0 0 0 0 0 0 0
50931 - 0 0 0 0 0 0 0 0 0 0 0 0
50932 - 0 0 0 0 0 0 0 0 0 0 0 0
50933 - 0 0 0 0 0 0 0 0 0 0 0 0
50934 - 0 0 0 0 0 0 0 0 0 0 0 0
50935 - 0 0 0 0 0 0 0 0 0 0 0 0
50936 - 0 0 0 0 0 0 6 6 6 18 18 18
50937 - 54 54 54 62 62 62 2 2 6 2 2 6
50938 - 2 2 6 30 30 30 46 46 46 70 70 70
50939 -250 250 250 253 253 253 253 253 253 253 253 253
50940 -253 253 253 253 253 253 253 253 253 253 253 253
50941 -253 253 253 253 253 253 231 231 231 246 246 246
50942 -253 253 253 253 253 253 253 253 253 253 253 253
50943 -253 253 253 253 253 253 253 253 253 253 253 253
50944 -253 253 253 253 253 253 253 253 253 253 253 253
50945 -253 253 253 253 253 253 253 253 253 253 253 253
50946 -253 253 253 253 253 253 226 226 226 10 10 10
50947 - 2 2 6 6 6 6 30 30 30 2 2 6
50948 - 2 2 6 2 2 6 2 2 6 2 2 6
50949 - 2 2 6 66 66 66 58 58 58 22 22 22
50950 - 6 6 6 0 0 0 0 0 0 0 0 0
50951 - 0 0 0 0 0 0 0 0 0 0 0 0
50952 - 0 0 0 0 0 0 0 0 0 0 0 0
50953 - 0 0 0 0 0 0 0 0 0 0 0 0
50954 - 0 0 0 0 0 0 0 0 0 0 0 0
50955 - 0 0 0 0 0 0 0 0 0 0 0 0
50956 - 0 0 0 0 0 0 6 6 6 22 22 22
50957 - 58 58 58 62 62 62 2 2 6 2 2 6
50958 - 2 2 6 2 2 6 30 30 30 78 78 78
50959 -250 250 250 253 253 253 253 253 253 253 253 253
50960 -253 253 253 253 253 253 253 253 253 253 253 253
50961 -253 253 253 253 253 253 231 231 231 246 246 246
50962 -253 253 253 253 253 253 253 253 253 253 253 253
50963 -253 253 253 253 253 253 253 253 253 253 253 253
50964 -253 253 253 253 253 253 253 253 253 253 253 253
50965 -253 253 253 253 253 253 253 253 253 253 253 253
50966 -253 253 253 253 253 253 206 206 206 2 2 6
50967 - 22 22 22 34 34 34 18 14 6 22 22 22
50968 - 26 26 26 18 18 18 6 6 6 2 2 6
50969 - 2 2 6 82 82 82 54 54 54 18 18 18
50970 - 6 6 6 0 0 0 0 0 0 0 0 0
50971 - 0 0 0 0 0 0 0 0 0 0 0 0
50972 - 0 0 0 0 0 0 0 0 0 0 0 0
50973 - 0 0 0 0 0 0 0 0 0 0 0 0
50974 - 0 0 0 0 0 0 0 0 0 0 0 0
50975 - 0 0 0 0 0 0 0 0 0 0 0 0
50976 - 0 0 0 0 0 0 6 6 6 26 26 26
50977 - 62 62 62 106 106 106 74 54 14 185 133 11
50978 -210 162 10 121 92 8 6 6 6 62 62 62
50979 -238 238 238 253 253 253 253 253 253 253 253 253
50980 -253 253 253 253 253 253 253 253 253 253 253 253
50981 -253 253 253 253 253 253 231 231 231 246 246 246
50982 -253 253 253 253 253 253 253 253 253 253 253 253
50983 -253 253 253 253 253 253 253 253 253 253 253 253
50984 -253 253 253 253 253 253 253 253 253 253 253 253
50985 -253 253 253 253 253 253 253 253 253 253 253 253
50986 -253 253 253 253 253 253 158 158 158 18 18 18
50987 - 14 14 14 2 2 6 2 2 6 2 2 6
50988 - 6 6 6 18 18 18 66 66 66 38 38 38
50989 - 6 6 6 94 94 94 50 50 50 18 18 18
50990 - 6 6 6 0 0 0 0 0 0 0 0 0
50991 - 0 0 0 0 0 0 0 0 0 0 0 0
50992 - 0 0 0 0 0 0 0 0 0 0 0 0
50993 - 0 0 0 0 0 0 0 0 0 0 0 0
50994 - 0 0 0 0 0 0 0 0 0 0 0 0
50995 - 0 0 0 0 0 0 0 0 0 6 6 6
50996 - 10 10 10 10 10 10 18 18 18 38 38 38
50997 - 78 78 78 142 134 106 216 158 10 242 186 14
50998 -246 190 14 246 190 14 156 118 10 10 10 10
50999 - 90 90 90 238 238 238 253 253 253 253 253 253
51000 -253 253 253 253 253 253 253 253 253 253 253 253
51001 -253 253 253 253 253 253 231 231 231 250 250 250
51002 -253 253 253 253 253 253 253 253 253 253 253 253
51003 -253 253 253 253 253 253 253 253 253 253 253 253
51004 -253 253 253 253 253 253 253 253 253 253 253 253
51005 -253 253 253 253 253 253 253 253 253 246 230 190
51006 -238 204 91 238 204 91 181 142 44 37 26 9
51007 - 2 2 6 2 2 6 2 2 6 2 2 6
51008 - 2 2 6 2 2 6 38 38 38 46 46 46
51009 - 26 26 26 106 106 106 54 54 54 18 18 18
51010 - 6 6 6 0 0 0 0 0 0 0 0 0
51011 - 0 0 0 0 0 0 0 0 0 0 0 0
51012 - 0 0 0 0 0 0 0 0 0 0 0 0
51013 - 0 0 0 0 0 0 0 0 0 0 0 0
51014 - 0 0 0 0 0 0 0 0 0 0 0 0
51015 - 0 0 0 6 6 6 14 14 14 22 22 22
51016 - 30 30 30 38 38 38 50 50 50 70 70 70
51017 -106 106 106 190 142 34 226 170 11 242 186 14
51018 -246 190 14 246 190 14 246 190 14 154 114 10
51019 - 6 6 6 74 74 74 226 226 226 253 253 253
51020 -253 253 253 253 253 253 253 253 253 253 253 253
51021 -253 253 253 253 253 253 231 231 231 250 250 250
51022 -253 253 253 253 253 253 253 253 253 253 253 253
51023 -253 253 253 253 253 253 253 253 253 253 253 253
51024 -253 253 253 253 253 253 253 253 253 253 253 253
51025 -253 253 253 253 253 253 253 253 253 228 184 62
51026 -241 196 14 241 208 19 232 195 16 38 30 10
51027 - 2 2 6 2 2 6 2 2 6 2 2 6
51028 - 2 2 6 6 6 6 30 30 30 26 26 26
51029 -203 166 17 154 142 90 66 66 66 26 26 26
51030 - 6 6 6 0 0 0 0 0 0 0 0 0
51031 - 0 0 0 0 0 0 0 0 0 0 0 0
51032 - 0 0 0 0 0 0 0 0 0 0 0 0
51033 - 0 0 0 0 0 0 0 0 0 0 0 0
51034 - 0 0 0 0 0 0 0 0 0 0 0 0
51035 - 6 6 6 18 18 18 38 38 38 58 58 58
51036 - 78 78 78 86 86 86 101 101 101 123 123 123
51037 -175 146 61 210 150 10 234 174 13 246 186 14
51038 -246 190 14 246 190 14 246 190 14 238 190 10
51039 -102 78 10 2 2 6 46 46 46 198 198 198
51040 -253 253 253 253 253 253 253 253 253 253 253 253
51041 -253 253 253 253 253 253 234 234 234 242 242 242
51042 -253 253 253 253 253 253 253 253 253 253 253 253
51043 -253 253 253 253 253 253 253 253 253 253 253 253
51044 -253 253 253 253 253 253 253 253 253 253 253 253
51045 -253 253 253 253 253 253 253 253 253 224 178 62
51046 -242 186 14 241 196 14 210 166 10 22 18 6
51047 - 2 2 6 2 2 6 2 2 6 2 2 6
51048 - 2 2 6 2 2 6 6 6 6 121 92 8
51049 -238 202 15 232 195 16 82 82 82 34 34 34
51050 - 10 10 10 0 0 0 0 0 0 0 0 0
51051 - 0 0 0 0 0 0 0 0 0 0 0 0
51052 - 0 0 0 0 0 0 0 0 0 0 0 0
51053 - 0 0 0 0 0 0 0 0 0 0 0 0
51054 - 0 0 0 0 0 0 0 0 0 0 0 0
51055 - 14 14 14 38 38 38 70 70 70 154 122 46
51056 -190 142 34 200 144 11 197 138 11 197 138 11
51057 -213 154 11 226 170 11 242 186 14 246 190 14
51058 -246 190 14 246 190 14 246 190 14 246 190 14
51059 -225 175 15 46 32 6 2 2 6 22 22 22
51060 -158 158 158 250 250 250 253 253 253 253 253 253
51061 -253 253 253 253 253 253 253 253 253 253 253 253
51062 -253 253 253 253 253 253 253 253 253 253 253 253
51063 -253 253 253 253 253 253 253 253 253 253 253 253
51064 -253 253 253 253 253 253 253 253 253 253 253 253
51065 -253 253 253 250 250 250 242 242 242 224 178 62
51066 -239 182 13 236 186 11 213 154 11 46 32 6
51067 - 2 2 6 2 2 6 2 2 6 2 2 6
51068 - 2 2 6 2 2 6 61 42 6 225 175 15
51069 -238 190 10 236 186 11 112 100 78 42 42 42
51070 - 14 14 14 0 0 0 0 0 0 0 0 0
51071 - 0 0 0 0 0 0 0 0 0 0 0 0
51072 - 0 0 0 0 0 0 0 0 0 0 0 0
51073 - 0 0 0 0 0 0 0 0 0 0 0 0
51074 - 0 0 0 0 0 0 0 0 0 6 6 6
51075 - 22 22 22 54 54 54 154 122 46 213 154 11
51076 -226 170 11 230 174 11 226 170 11 226 170 11
51077 -236 178 12 242 186 14 246 190 14 246 190 14
51078 -246 190 14 246 190 14 246 190 14 246 190 14
51079 -241 196 14 184 144 12 10 10 10 2 2 6
51080 - 6 6 6 116 116 116 242 242 242 253 253 253
51081 -253 253 253 253 253 253 253 253 253 253 253 253
51082 -253 253 253 253 253 253 253 253 253 253 253 253
51083 -253 253 253 253 253 253 253 253 253 253 253 253
51084 -253 253 253 253 253 253 253 253 253 253 253 253
51085 -253 253 253 231 231 231 198 198 198 214 170 54
51086 -236 178 12 236 178 12 210 150 10 137 92 6
51087 - 18 14 6 2 2 6 2 2 6 2 2 6
51088 - 6 6 6 70 47 6 200 144 11 236 178 12
51089 -239 182 13 239 182 13 124 112 88 58 58 58
51090 - 22 22 22 6 6 6 0 0 0 0 0 0
51091 - 0 0 0 0 0 0 0 0 0 0 0 0
51092 - 0 0 0 0 0 0 0 0 0 0 0 0
51093 - 0 0 0 0 0 0 0 0 0 0 0 0
51094 - 0 0 0 0 0 0 0 0 0 10 10 10
51095 - 30 30 30 70 70 70 180 133 36 226 170 11
51096 -239 182 13 242 186 14 242 186 14 246 186 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 232 195 16 98 70 6 2 2 6
51100 - 2 2 6 2 2 6 66 66 66 221 221 221
51101 -253 253 253 253 253 253 253 253 253 253 253 253
51102 -253 253 253 253 253 253 253 253 253 253 253 253
51103 -253 253 253 253 253 253 253 253 253 253 253 253
51104 -253 253 253 253 253 253 253 253 253 253 253 253
51105 -253 253 253 206 206 206 198 198 198 214 166 58
51106 -230 174 11 230 174 11 216 158 10 192 133 9
51107 -163 110 8 116 81 8 102 78 10 116 81 8
51108 -167 114 7 197 138 11 226 170 11 239 182 13
51109 -242 186 14 242 186 14 162 146 94 78 78 78
51110 - 34 34 34 14 14 14 6 6 6 0 0 0
51111 - 0 0 0 0 0 0 0 0 0 0 0 0
51112 - 0 0 0 0 0 0 0 0 0 0 0 0
51113 - 0 0 0 0 0 0 0 0 0 0 0 0
51114 - 0 0 0 0 0 0 0 0 0 6 6 6
51115 - 30 30 30 78 78 78 190 142 34 226 170 11
51116 -239 182 13 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 241 196 14 203 166 17 22 18 6
51120 - 2 2 6 2 2 6 2 2 6 38 38 38
51121 -218 218 218 253 253 253 253 253 253 253 253 253
51122 -253 253 253 253 253 253 253 253 253 253 253 253
51123 -253 253 253 253 253 253 253 253 253 253 253 253
51124 -253 253 253 253 253 253 253 253 253 253 253 253
51125 -250 250 250 206 206 206 198 198 198 202 162 69
51126 -226 170 11 236 178 12 224 166 10 210 150 10
51127 -200 144 11 197 138 11 192 133 9 197 138 11
51128 -210 150 10 226 170 11 242 186 14 246 190 14
51129 -246 190 14 246 186 14 225 175 15 124 112 88
51130 - 62 62 62 30 30 30 14 14 14 6 6 6
51131 - 0 0 0 0 0 0 0 0 0 0 0 0
51132 - 0 0 0 0 0 0 0 0 0 0 0 0
51133 - 0 0 0 0 0 0 0 0 0 0 0 0
51134 - 0 0 0 0 0 0 0 0 0 10 10 10
51135 - 30 30 30 78 78 78 174 135 50 224 166 10
51136 -239 182 13 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 190 14 246 190 14 241 196 14 139 102 15
51140 - 2 2 6 2 2 6 2 2 6 2 2 6
51141 - 78 78 78 250 250 250 253 253 253 253 253 253
51142 -253 253 253 253 253 253 253 253 253 253 253 253
51143 -253 253 253 253 253 253 253 253 253 253 253 253
51144 -253 253 253 253 253 253 253 253 253 253 253 253
51145 -250 250 250 214 214 214 198 198 198 190 150 46
51146 -219 162 10 236 178 12 234 174 13 224 166 10
51147 -216 158 10 213 154 11 213 154 11 216 158 10
51148 -226 170 11 239 182 13 246 190 14 246 190 14
51149 -246 190 14 246 190 14 242 186 14 206 162 42
51150 -101 101 101 58 58 58 30 30 30 14 14 14
51151 - 6 6 6 0 0 0 0 0 0 0 0 0
51152 - 0 0 0 0 0 0 0 0 0 0 0 0
51153 - 0 0 0 0 0 0 0 0 0 0 0 0
51154 - 0 0 0 0 0 0 0 0 0 10 10 10
51155 - 30 30 30 74 74 74 174 135 50 216 158 10
51156 -236 178 12 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 246 190 14
51159 -246 190 14 246 190 14 241 196 14 226 184 13
51160 - 61 42 6 2 2 6 2 2 6 2 2 6
51161 - 22 22 22 238 238 238 253 253 253 253 253 253
51162 -253 253 253 253 253 253 253 253 253 253 253 253
51163 -253 253 253 253 253 253 253 253 253 253 253 253
51164 -253 253 253 253 253 253 253 253 253 253 253 253
51165 -253 253 253 226 226 226 187 187 187 180 133 36
51166 -216 158 10 236 178 12 239 182 13 236 178 12
51167 -230 174 11 226 170 11 226 170 11 230 174 11
51168 -236 178 12 242 186 14 246 190 14 246 190 14
51169 -246 190 14 246 190 14 246 186 14 239 182 13
51170 -206 162 42 106 106 106 66 66 66 34 34 34
51171 - 14 14 14 6 6 6 0 0 0 0 0 0
51172 - 0 0 0 0 0 0 0 0 0 0 0 0
51173 - 0 0 0 0 0 0 0 0 0 0 0 0
51174 - 0 0 0 0 0 0 0 0 0 6 6 6
51175 - 26 26 26 70 70 70 163 133 67 213 154 11
51176 -236 178 12 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 246 190 14 246 190 14 246 190 14
51179 -246 190 14 246 190 14 246 190 14 241 196 14
51180 -190 146 13 18 14 6 2 2 6 2 2 6
51181 - 46 46 46 246 246 246 253 253 253 253 253 253
51182 -253 253 253 253 253 253 253 253 253 253 253 253
51183 -253 253 253 253 253 253 253 253 253 253 253 253
51184 -253 253 253 253 253 253 253 253 253 253 253 253
51185 -253 253 253 221 221 221 86 86 86 156 107 11
51186 -216 158 10 236 178 12 242 186 14 246 186 14
51187 -242 186 14 239 182 13 239 182 13 242 186 14
51188 -242 186 14 246 186 14 246 190 14 246 190 14
51189 -246 190 14 246 190 14 246 190 14 246 190 14
51190 -242 186 14 225 175 15 142 122 72 66 66 66
51191 - 30 30 30 10 10 10 0 0 0 0 0 0
51192 - 0 0 0 0 0 0 0 0 0 0 0 0
51193 - 0 0 0 0 0 0 0 0 0 0 0 0
51194 - 0 0 0 0 0 0 0 0 0 6 6 6
51195 - 26 26 26 70 70 70 163 133 67 210 150 10
51196 -236 178 12 246 190 14 246 190 14 246 190 14
51197 -246 190 14 246 190 14 246 190 14 246 190 14
51198 -246 190 14 246 190 14 246 190 14 246 190 14
51199 -246 190 14 246 190 14 246 190 14 246 190 14
51200 -232 195 16 121 92 8 34 34 34 106 106 106
51201 -221 221 221 253 253 253 253 253 253 253 253 253
51202 -253 253 253 253 253 253 253 253 253 253 253 253
51203 -253 253 253 253 253 253 253 253 253 253 253 253
51204 -253 253 253 253 253 253 253 253 253 253 253 253
51205 -242 242 242 82 82 82 18 14 6 163 110 8
51206 -216 158 10 236 178 12 242 186 14 246 190 14
51207 -246 190 14 246 190 14 246 190 14 246 190 14
51208 -246 190 14 246 190 14 246 190 14 246 190 14
51209 -246 190 14 246 190 14 246 190 14 246 190 14
51210 -246 190 14 246 190 14 242 186 14 163 133 67
51211 - 46 46 46 18 18 18 6 6 6 0 0 0
51212 - 0 0 0 0 0 0 0 0 0 0 0 0
51213 - 0 0 0 0 0 0 0 0 0 0 0 0
51214 - 0 0 0 0 0 0 0 0 0 10 10 10
51215 - 30 30 30 78 78 78 163 133 67 210 150 10
51216 -236 178 12 246 186 14 246 190 14 246 190 14
51217 -246 190 14 246 190 14 246 190 14 246 190 14
51218 -246 190 14 246 190 14 246 190 14 246 190 14
51219 -246 190 14 246 190 14 246 190 14 246 190 14
51220 -241 196 14 215 174 15 190 178 144 253 253 253
51221 -253 253 253 253 253 253 253 253 253 253 253 253
51222 -253 253 253 253 253 253 253 253 253 253 253 253
51223 -253 253 253 253 253 253 253 253 253 253 253 253
51224 -253 253 253 253 253 253 253 253 253 218 218 218
51225 - 58 58 58 2 2 6 22 18 6 167 114 7
51226 -216 158 10 236 178 12 246 186 14 246 190 14
51227 -246 190 14 246 190 14 246 190 14 246 190 14
51228 -246 190 14 246 190 14 246 190 14 246 190 14
51229 -246 190 14 246 190 14 246 190 14 246 190 14
51230 -246 190 14 246 186 14 242 186 14 190 150 46
51231 - 54 54 54 22 22 22 6 6 6 0 0 0
51232 - 0 0 0 0 0 0 0 0 0 0 0 0
51233 - 0 0 0 0 0 0 0 0 0 0 0 0
51234 - 0 0 0 0 0 0 0 0 0 14 14 14
51235 - 38 38 38 86 86 86 180 133 36 213 154 11
51236 -236 178 12 246 186 14 246 190 14 246 190 14
51237 -246 190 14 246 190 14 246 190 14 246 190 14
51238 -246 190 14 246 190 14 246 190 14 246 190 14
51239 -246 190 14 246 190 14 246 190 14 246 190 14
51240 -246 190 14 232 195 16 190 146 13 214 214 214
51241 -253 253 253 253 253 253 253 253 253 253 253 253
51242 -253 253 253 253 253 253 253 253 253 253 253 253
51243 -253 253 253 253 253 253 253 253 253 253 253 253
51244 -253 253 253 250 250 250 170 170 170 26 26 26
51245 - 2 2 6 2 2 6 37 26 9 163 110 8
51246 -219 162 10 239 182 13 246 186 14 246 190 14
51247 -246 190 14 246 190 14 246 190 14 246 190 14
51248 -246 190 14 246 190 14 246 190 14 246 190 14
51249 -246 190 14 246 190 14 246 190 14 246 190 14
51250 -246 186 14 236 178 12 224 166 10 142 122 72
51251 - 46 46 46 18 18 18 6 6 6 0 0 0
51252 - 0 0 0 0 0 0 0 0 0 0 0 0
51253 - 0 0 0 0 0 0 0 0 0 0 0 0
51254 - 0 0 0 0 0 0 6 6 6 18 18 18
51255 - 50 50 50 109 106 95 192 133 9 224 166 10
51256 -242 186 14 246 190 14 246 190 14 246 190 14
51257 -246 190 14 246 190 14 246 190 14 246 190 14
51258 -246 190 14 246 190 14 246 190 14 246 190 14
51259 -246 190 14 246 190 14 246 190 14 246 190 14
51260 -242 186 14 226 184 13 210 162 10 142 110 46
51261 -226 226 226 253 253 253 253 253 253 253 253 253
51262 -253 253 253 253 253 253 253 253 253 253 253 253
51263 -253 253 253 253 253 253 253 253 253 253 253 253
51264 -198 198 198 66 66 66 2 2 6 2 2 6
51265 - 2 2 6 2 2 6 50 34 6 156 107 11
51266 -219 162 10 239 182 13 246 186 14 246 190 14
51267 -246 190 14 246 190 14 246 190 14 246 190 14
51268 -246 190 14 246 190 14 246 190 14 246 190 14
51269 -246 190 14 246 190 14 246 190 14 242 186 14
51270 -234 174 13 213 154 11 154 122 46 66 66 66
51271 - 30 30 30 10 10 10 0 0 0 0 0 0
51272 - 0 0 0 0 0 0 0 0 0 0 0 0
51273 - 0 0 0 0 0 0 0 0 0 0 0 0
51274 - 0 0 0 0 0 0 6 6 6 22 22 22
51275 - 58 58 58 154 121 60 206 145 10 234 174 13
51276 -242 186 14 246 186 14 246 190 14 246 190 14
51277 -246 190 14 246 190 14 246 190 14 246 190 14
51278 -246 190 14 246 190 14 246 190 14 246 190 14
51279 -246 190 14 246 190 14 246 190 14 246 190 14
51280 -246 186 14 236 178 12 210 162 10 163 110 8
51281 - 61 42 6 138 138 138 218 218 218 250 250 250
51282 -253 253 253 253 253 253 253 253 253 250 250 250
51283 -242 242 242 210 210 210 144 144 144 66 66 66
51284 - 6 6 6 2 2 6 2 2 6 2 2 6
51285 - 2 2 6 2 2 6 61 42 6 163 110 8
51286 -216 158 10 236 178 12 246 190 14 246 190 14
51287 -246 190 14 246 190 14 246 190 14 246 190 14
51288 -246 190 14 246 190 14 246 190 14 246 190 14
51289 -246 190 14 239 182 13 230 174 11 216 158 10
51290 -190 142 34 124 112 88 70 70 70 38 38 38
51291 - 18 18 18 6 6 6 0 0 0 0 0 0
51292 - 0 0 0 0 0 0 0 0 0 0 0 0
51293 - 0 0 0 0 0 0 0 0 0 0 0 0
51294 - 0 0 0 0 0 0 6 6 6 22 22 22
51295 - 62 62 62 168 124 44 206 145 10 224 166 10
51296 -236 178 12 239 182 13 242 186 14 242 186 14
51297 -246 186 14 246 190 14 246 190 14 246 190 14
51298 -246 190 14 246 190 14 246 190 14 246 190 14
51299 -246 190 14 246 190 14 246 190 14 246 190 14
51300 -246 190 14 236 178 12 216 158 10 175 118 6
51301 - 80 54 7 2 2 6 6 6 6 30 30 30
51302 - 54 54 54 62 62 62 50 50 50 38 38 38
51303 - 14 14 14 2 2 6 2 2 6 2 2 6
51304 - 2 2 6 2 2 6 2 2 6 2 2 6
51305 - 2 2 6 6 6 6 80 54 7 167 114 7
51306 -213 154 11 236 178 12 246 190 14 246 190 14
51307 -246 190 14 246 190 14 246 190 14 246 190 14
51308 -246 190 14 242 186 14 239 182 13 239 182 13
51309 -230 174 11 210 150 10 174 135 50 124 112 88
51310 - 82 82 82 54 54 54 34 34 34 18 18 18
51311 - 6 6 6 0 0 0 0 0 0 0 0 0
51312 - 0 0 0 0 0 0 0 0 0 0 0 0
51313 - 0 0 0 0 0 0 0 0 0 0 0 0
51314 - 0 0 0 0 0 0 6 6 6 18 18 18
51315 - 50 50 50 158 118 36 192 133 9 200 144 11
51316 -216 158 10 219 162 10 224 166 10 226 170 11
51317 -230 174 11 236 178 12 239 182 13 239 182 13
51318 -242 186 14 246 186 14 246 190 14 246 190 14
51319 -246 190 14 246 190 14 246 190 14 246 190 14
51320 -246 186 14 230 174 11 210 150 10 163 110 8
51321 -104 69 6 10 10 10 2 2 6 2 2 6
51322 - 2 2 6 2 2 6 2 2 6 2 2 6
51323 - 2 2 6 2 2 6 2 2 6 2 2 6
51324 - 2 2 6 2 2 6 2 2 6 2 2 6
51325 - 2 2 6 6 6 6 91 60 6 167 114 7
51326 -206 145 10 230 174 11 242 186 14 246 190 14
51327 -246 190 14 246 190 14 246 186 14 242 186 14
51328 -239 182 13 230 174 11 224 166 10 213 154 11
51329 -180 133 36 124 112 88 86 86 86 58 58 58
51330 - 38 38 38 22 22 22 10 10 10 6 6 6
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 - 0 0 0 0 0 0 0 0 0 14 14 14
51335 - 34 34 34 70 70 70 138 110 50 158 118 36
51336 -167 114 7 180 123 7 192 133 9 197 138 11
51337 -200 144 11 206 145 10 213 154 11 219 162 10
51338 -224 166 10 230 174 11 239 182 13 242 186 14
51339 -246 186 14 246 186 14 246 186 14 246 186 14
51340 -239 182 13 216 158 10 185 133 11 152 99 6
51341 -104 69 6 18 14 6 2 2 6 2 2 6
51342 - 2 2 6 2 2 6 2 2 6 2 2 6
51343 - 2 2 6 2 2 6 2 2 6 2 2 6
51344 - 2 2 6 2 2 6 2 2 6 2 2 6
51345 - 2 2 6 6 6 6 80 54 7 152 99 6
51346 -192 133 9 219 162 10 236 178 12 239 182 13
51347 -246 186 14 242 186 14 239 182 13 236 178 12
51348 -224 166 10 206 145 10 192 133 9 154 121 60
51349 - 94 94 94 62 62 62 42 42 42 22 22 22
51350 - 14 14 14 6 6 6 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 0 0 0 0 0 0 6 6 6
51355 - 18 18 18 34 34 34 58 58 58 78 78 78
51356 -101 98 89 124 112 88 142 110 46 156 107 11
51357 -163 110 8 167 114 7 175 118 6 180 123 7
51358 -185 133 11 197 138 11 210 150 10 219 162 10
51359 -226 170 11 236 178 12 236 178 12 234 174 13
51360 -219 162 10 197 138 11 163 110 8 130 83 6
51361 - 91 60 6 10 10 10 2 2 6 2 2 6
51362 - 18 18 18 38 38 38 38 38 38 38 38 38
51363 - 38 38 38 38 38 38 38 38 38 38 38 38
51364 - 38 38 38 38 38 38 26 26 26 2 2 6
51365 - 2 2 6 6 6 6 70 47 6 137 92 6
51366 -175 118 6 200 144 11 219 162 10 230 174 11
51367 -234 174 13 230 174 11 219 162 10 210 150 10
51368 -192 133 9 163 110 8 124 112 88 82 82 82
51369 - 50 50 50 30 30 30 14 14 14 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 0 0 0
51375 - 6 6 6 14 14 14 22 22 22 34 34 34
51376 - 42 42 42 58 58 58 74 74 74 86 86 86
51377 -101 98 89 122 102 70 130 98 46 121 87 25
51378 -137 92 6 152 99 6 163 110 8 180 123 7
51379 -185 133 11 197 138 11 206 145 10 200 144 11
51380 -180 123 7 156 107 11 130 83 6 104 69 6
51381 - 50 34 6 54 54 54 110 110 110 101 98 89
51382 - 86 86 86 82 82 82 78 78 78 78 78 78
51383 - 78 78 78 78 78 78 78 78 78 78 78 78
51384 - 78 78 78 82 82 82 86 86 86 94 94 94
51385 -106 106 106 101 101 101 86 66 34 124 80 6
51386 -156 107 11 180 123 7 192 133 9 200 144 11
51387 -206 145 10 200 144 11 192 133 9 175 118 6
51388 -139 102 15 109 106 95 70 70 70 42 42 42
51389 - 22 22 22 10 10 10 0 0 0 0 0 0
51390 - 0 0 0 0 0 0 0 0 0 0 0 0
51391 - 0 0 0 0 0 0 0 0 0 0 0 0
51392 - 0 0 0 0 0 0 0 0 0 0 0 0
51393 - 0 0 0 0 0 0 0 0 0 0 0 0
51394 - 0 0 0 0 0 0 0 0 0 0 0 0
51395 - 0 0 0 0 0 0 6 6 6 10 10 10
51396 - 14 14 14 22 22 22 30 30 30 38 38 38
51397 - 50 50 50 62 62 62 74 74 74 90 90 90
51398 -101 98 89 112 100 78 121 87 25 124 80 6
51399 -137 92 6 152 99 6 152 99 6 152 99 6
51400 -138 86 6 124 80 6 98 70 6 86 66 30
51401 -101 98 89 82 82 82 58 58 58 46 46 46
51402 - 38 38 38 34 34 34 34 34 34 34 34 34
51403 - 34 34 34 34 34 34 34 34 34 34 34 34
51404 - 34 34 34 34 34 34 38 38 38 42 42 42
51405 - 54 54 54 82 82 82 94 86 76 91 60 6
51406 -134 86 6 156 107 11 167 114 7 175 118 6
51407 -175 118 6 167 114 7 152 99 6 121 87 25
51408 -101 98 89 62 62 62 34 34 34 18 18 18
51409 - 6 6 6 0 0 0 0 0 0 0 0 0
51410 - 0 0 0 0 0 0 0 0 0 0 0 0
51411 - 0 0 0 0 0 0 0 0 0 0 0 0
51412 - 0 0 0 0 0 0 0 0 0 0 0 0
51413 - 0 0 0 0 0 0 0 0 0 0 0 0
51414 - 0 0 0 0 0 0 0 0 0 0 0 0
51415 - 0 0 0 0 0 0 0 0 0 0 0 0
51416 - 0 0 0 6 6 6 6 6 6 10 10 10
51417 - 18 18 18 22 22 22 30 30 30 42 42 42
51418 - 50 50 50 66 66 66 86 86 86 101 98 89
51419 -106 86 58 98 70 6 104 69 6 104 69 6
51420 -104 69 6 91 60 6 82 62 34 90 90 90
51421 - 62 62 62 38 38 38 22 22 22 14 14 14
51422 - 10 10 10 10 10 10 10 10 10 10 10 10
51423 - 10 10 10 10 10 10 6 6 6 10 10 10
51424 - 10 10 10 10 10 10 10 10 10 14 14 14
51425 - 22 22 22 42 42 42 70 70 70 89 81 66
51426 - 80 54 7 104 69 6 124 80 6 137 92 6
51427 -134 86 6 116 81 8 100 82 52 86 86 86
51428 - 58 58 58 30 30 30 14 14 14 6 6 6
51429 - 0 0 0 0 0 0 0 0 0 0 0 0
51430 - 0 0 0 0 0 0 0 0 0 0 0 0
51431 - 0 0 0 0 0 0 0 0 0 0 0 0
51432 - 0 0 0 0 0 0 0 0 0 0 0 0
51433 - 0 0 0 0 0 0 0 0 0 0 0 0
51434 - 0 0 0 0 0 0 0 0 0 0 0 0
51435 - 0 0 0 0 0 0 0 0 0 0 0 0
51436 - 0 0 0 0 0 0 0 0 0 0 0 0
51437 - 0 0 0 6 6 6 10 10 10 14 14 14
51438 - 18 18 18 26 26 26 38 38 38 54 54 54
51439 - 70 70 70 86 86 86 94 86 76 89 81 66
51440 - 89 81 66 86 86 86 74 74 74 50 50 50
51441 - 30 30 30 14 14 14 6 6 6 0 0 0
51442 - 0 0 0 0 0 0 0 0 0 0 0 0
51443 - 0 0 0 0 0 0 0 0 0 0 0 0
51444 - 0 0 0 0 0 0 0 0 0 0 0 0
51445 - 6 6 6 18 18 18 34 34 34 58 58 58
51446 - 82 82 82 89 81 66 89 81 66 89 81 66
51447 - 94 86 66 94 86 76 74 74 74 50 50 50
51448 - 26 26 26 14 14 14 6 6 6 0 0 0
51449 - 0 0 0 0 0 0 0 0 0 0 0 0
51450 - 0 0 0 0 0 0 0 0 0 0 0 0
51451 - 0 0 0 0 0 0 0 0 0 0 0 0
51452 - 0 0 0 0 0 0 0 0 0 0 0 0
51453 - 0 0 0 0 0 0 0 0 0 0 0 0
51454 - 0 0 0 0 0 0 0 0 0 0 0 0
51455 - 0 0 0 0 0 0 0 0 0 0 0 0
51456 - 0 0 0 0 0 0 0 0 0 0 0 0
51457 - 0 0 0 0 0 0 0 0 0 0 0 0
51458 - 6 6 6 6 6 6 14 14 14 18 18 18
51459 - 30 30 30 38 38 38 46 46 46 54 54 54
51460 - 50 50 50 42 42 42 30 30 30 18 18 18
51461 - 10 10 10 0 0 0 0 0 0 0 0 0
51462 - 0 0 0 0 0 0 0 0 0 0 0 0
51463 - 0 0 0 0 0 0 0 0 0 0 0 0
51464 - 0 0 0 0 0 0 0 0 0 0 0 0
51465 - 0 0 0 6 6 6 14 14 14 26 26 26
51466 - 38 38 38 50 50 50 58 58 58 58 58 58
51467 - 54 54 54 42 42 42 30 30 30 18 18 18
51468 - 10 10 10 0 0 0 0 0 0 0 0 0
51469 - 0 0 0 0 0 0 0 0 0 0 0 0
51470 - 0 0 0 0 0 0 0 0 0 0 0 0
51471 - 0 0 0 0 0 0 0 0 0 0 0 0
51472 - 0 0 0 0 0 0 0 0 0 0 0 0
51473 - 0 0 0 0 0 0 0 0 0 0 0 0
51474 - 0 0 0 0 0 0 0 0 0 0 0 0
51475 - 0 0 0 0 0 0 0 0 0 0 0 0
51476 - 0 0 0 0 0 0 0 0 0 0 0 0
51477 - 0 0 0 0 0 0 0 0 0 0 0 0
51478 - 0 0 0 0 0 0 0 0 0 6 6 6
51479 - 6 6 6 10 10 10 14 14 14 18 18 18
51480 - 18 18 18 14 14 14 10 10 10 6 6 6
51481 - 0 0 0 0 0 0 0 0 0 0 0 0
51482 - 0 0 0 0 0 0 0 0 0 0 0 0
51483 - 0 0 0 0 0 0 0 0 0 0 0 0
51484 - 0 0 0 0 0 0 0 0 0 0 0 0
51485 - 0 0 0 0 0 0 0 0 0 6 6 6
51486 - 14 14 14 18 18 18 22 22 22 22 22 22
51487 - 18 18 18 14 14 14 10 10 10 6 6 6
51488 - 0 0 0 0 0 0 0 0 0 0 0 0
51489 - 0 0 0 0 0 0 0 0 0 0 0 0
51490 - 0 0 0 0 0 0 0 0 0 0 0 0
51491 - 0 0 0 0 0 0 0 0 0 0 0 0
51492 - 0 0 0 0 0 0 0 0 0 0 0 0
51493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51506 +4 4 4 4 4 4
51507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51520 +4 4 4 4 4 4
51521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51534 +4 4 4 4 4 4
51535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51548 +4 4 4 4 4 4
51549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51562 +4 4 4 4 4 4
51563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51576 +4 4 4 4 4 4
51577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51581 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51582 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51587 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51588 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51590 +4 4 4 4 4 4
51591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51595 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51596 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51597 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51601 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51602 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51603 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51604 +4 4 4 4 4 4
51605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51609 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51610 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51611 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51614 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51615 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51616 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51617 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51618 +4 4 4 4 4 4
51619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51622 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51623 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51624 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51625 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51628 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51629 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51630 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51631 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51632 +4 4 4 4 4 4
51633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51636 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51637 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51638 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51639 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51640 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51641 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51642 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51643 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51644 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51645 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51646 +4 4 4 4 4 4
51647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51650 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51651 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51652 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51653 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51654 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51655 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51656 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51657 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51658 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51659 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51660 +4 4 4 4 4 4
51661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51663 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51664 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51665 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51666 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51667 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51668 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51669 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51670 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51671 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51672 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51673 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 4 4
51675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51677 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51678 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51679 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51680 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51681 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51682 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51683 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51684 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51685 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51686 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51687 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51688 +4 4 4 4 4 4
51689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51691 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51692 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51693 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51694 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51695 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51696 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51697 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51698 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51699 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51700 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51701 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51702 +4 4 4 4 4 4
51703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51705 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51706 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51707 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51708 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51709 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51710 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51711 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51712 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51713 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51714 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51715 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51716 +4 4 4 4 4 4
51717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51718 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51719 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51720 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51721 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51722 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51723 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51724 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51725 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51726 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51727 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51728 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51729 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51730 +4 4 4 4 4 4
51731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51732 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51733 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51734 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51735 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51736 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51737 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51738 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51739 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51740 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51741 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51742 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51743 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51744 +0 0 0 4 4 4
51745 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51746 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51747 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51748 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51749 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51750 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51751 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51752 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51753 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51754 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51755 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51756 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51757 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51758 +2 0 0 0 0 0
51759 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51760 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51761 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51762 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51763 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51764 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51765 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51766 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51767 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51768 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51769 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51770 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51771 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51772 +37 38 37 0 0 0
51773 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51774 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51775 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51776 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51777 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51778 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51779 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51780 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51781 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51782 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51783 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51784 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51785 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51786 +85 115 134 4 0 0
51787 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51788 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51789 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51790 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51791 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51792 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51793 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51794 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51795 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51796 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51797 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51798 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51799 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51800 +60 73 81 4 0 0
51801 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51802 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51803 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51804 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51805 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51806 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51807 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51808 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51809 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51810 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51811 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51812 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51813 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51814 +16 19 21 4 0 0
51815 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51816 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51817 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51818 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51819 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51820 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51821 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51822 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51823 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51824 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51825 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51826 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51827 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51828 +4 0 0 4 3 3
51829 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51830 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51831 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51833 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51834 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51835 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51836 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51837 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51838 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51839 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51840 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51841 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51842 +3 2 2 4 4 4
51843 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51844 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51845 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51846 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51847 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51848 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51849 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51850 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51851 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51852 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51853 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51854 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51855 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51856 +4 4 4 4 4 4
51857 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51858 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51859 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51860 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51861 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51862 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51863 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51864 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51865 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51866 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51867 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51868 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51869 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51870 +4 4 4 4 4 4
51871 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51872 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51873 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51874 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51875 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51876 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51877 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51878 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51879 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51880 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51881 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51882 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51883 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51884 +5 5 5 5 5 5
51885 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51886 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51887 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51888 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51889 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51890 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51891 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51892 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51893 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51894 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51895 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51896 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51897 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51898 +5 5 5 4 4 4
51899 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51900 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51901 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51902 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51903 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51904 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51905 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51906 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51907 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51908 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51909 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51910 +4 0 0 4 0 0 5 5 5 5 5 5 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
51913 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51914 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51915 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51916 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51917 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51918 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51919 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51920 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51921 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51922 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51923 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51924 +3 3 3 5 5 5 6 6 6 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
51927 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51928 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51929 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51930 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51931 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51932 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51933 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51934 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51935 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51936 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51937 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51938 +4 4 4 4 4 4 4 4 4 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
51941 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51942 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51943 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51944 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51945 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51946 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51947 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51948 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51949 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51950 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51951 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51952 +4 4 4 4 4 4 4 4 4 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
51955 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51956 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51957 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51958 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51959 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51960 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51961 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51962 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51963 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51964 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51965 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51966 +4 4 4 4 4 4 4 4 4 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
51969 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51970 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51971 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51972 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51973 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51974 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51975 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51976 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51977 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51978 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51979 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51980 +4 4 4 4 4 4 4 4 4 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
51983 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51984 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51985 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51986 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51987 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51988 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51989 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51990 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51991 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51992 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51993 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51994 +4 4 4 4 4 4 4 4 4 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
51997 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51998 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51999 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
52000 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52001 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
52002 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
52003 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
52004 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
52005 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
52006 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
52007 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52008 +4 4 4 4 4 4 4 4 4 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
52011 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
52012 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
52013 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
52014 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52015 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52016 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
52017 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
52018 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
52019 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
52020 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
52021 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52022 +4 4 4 4 4 4 4 4 4 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
52025 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
52026 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
52027 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52028 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52029 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52030 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
52031 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
52032 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
52033 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
52034 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
52035 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52036 +4 4 4 4 4 4 4 4 4 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
52039 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
52040 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
52041 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52042 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52043 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52044 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
52045 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
52046 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
52047 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52048 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52049 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52050 +4 4 4 4 4 4 4 4 4 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
52053 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52054 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
52055 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52056 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
52057 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
52058 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
52059 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
52060 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
52061 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52062 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52063 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52064 +4 4 4 4 4 4 4 4 4 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
52067 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52068 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
52069 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52070 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
52071 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52072 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
52073 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
52074 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
52075 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52076 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52077 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52078 +4 4 4 4 4 4 4 4 4 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
52081 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
52082 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
52083 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52084 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
52085 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
52086 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
52087 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
52088 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
52089 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52090 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52091 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52092 +4 4 4 4 4 4 4 4 4 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
52095 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
52096 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
52097 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52098 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
52099 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
52100 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
52101 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
52102 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
52103 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52104 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52105 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52106 +4 4 4 4 4 4 4 4 4 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
52109 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52110 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
52111 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52112 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
52113 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
52114 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
52115 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
52116 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
52117 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52118 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52119 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52120 +4 4 4 4 4 4 4 4 4 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
52123 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
52124 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
52125 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52126 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
52127 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
52128 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
52129 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
52130 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
52131 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
52132 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52133 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52134 +4 4 4 4 4 4 4 4 4 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
52137 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52138 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
52139 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
52140 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
52141 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
52142 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
52143 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
52144 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
52145 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52146 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52147 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52148 +4 4 4 4 4 4 4 4 4 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
52151 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52152 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
52153 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52154 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
52155 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
52156 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
52157 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
52158 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
52159 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52160 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52161 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52162 +4 4 4 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
52165 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52166 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
52167 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
52168 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
52169 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
52170 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
52171 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52172 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
52173 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52174 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52175 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52176 +4 4 4 4 4 4 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
52179 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52180 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
52181 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
52182 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52183 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
52184 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
52185 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52186 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
52187 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52188 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52189 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52190 +4 4 4 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
52193 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52194 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
52195 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
52196 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
52197 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
52198 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
52199 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
52200 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
52201 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
52202 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52203 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
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
52207 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52208 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
52209 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
52210 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
52211 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
52212 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
52213 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
52214 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
52215 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
52216 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52217 +0 0 0 3 3 3 5 5 5 4 4 4 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
52221 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
52222 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
52223 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
52224 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
52225 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52226 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
52227 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
52228 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
52229 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
52230 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52231 +0 0 0 3 3 3 5 5 5 4 4 4 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
52235 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52236 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
52237 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
52238 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
52239 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
52240 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
52241 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
52242 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
52243 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
52244 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52245 +0 0 0 3 3 3 5 5 5 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
52249 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
52250 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
52251 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
52252 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
52253 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
52254 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
52255 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
52256 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
52257 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
52258 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
52259 +0 0 0 3 3 3 5 5 5 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
52263 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
52264 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52265 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
52266 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
52267 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
52268 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
52269 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
52270 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
52271 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
52272 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
52273 +0 0 0 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
52277 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
52278 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52279 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
52280 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
52281 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
52282 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
52283 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52284 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
52285 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
52286 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
52287 +4 3 3 5 5 5 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
52291 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
52292 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
52293 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
52294 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
52295 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
52296 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
52297 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
52298 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
52299 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
52300 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
52301 +5 5 5 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
52305 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
52306 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
52307 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52308 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
52309 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
52310 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
52311 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
52312 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
52313 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
52314 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
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
52319 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52320 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
52321 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
52322 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
52323 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
52324 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
52325 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
52326 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
52327 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
52328 +13 16 17 4 0 0 4 0 0 4 3 3 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
52333 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
52334 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
52335 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
52336 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
52337 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
52338 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
52339 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
52340 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
52341 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
52342 +4 0 0 4 0 0 5 5 5 5 5 5 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
52347 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
52348 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
52349 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
52350 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
52351 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
52352 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
52353 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
52354 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
52355 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52356 +4 3 3 5 5 5 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
52361 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
52362 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52363 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
52364 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52365 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
52366 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
52367 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
52368 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
52369 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
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
52375 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
52376 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
52377 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
52378 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
52379 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
52380 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
52381 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
52382 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
52383 +4 0 0 4 0 0 4 0 0 6 6 6 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
52389 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52390 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
52391 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
52392 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
52393 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
52394 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
52395 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
52396 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
52397 +4 0 0 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
52403 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
52404 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
52405 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52406 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
52407 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
52408 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
52409 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
52410 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
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
52417 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52418 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
52419 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
52420 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
52421 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
52422 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
52423 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
52424 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 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
52431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52432 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
52433 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52434 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
52435 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
52436 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
52437 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
52438 +4 0 0 4 3 3 6 6 6 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
52445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52446 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
52447 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
52448 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
52449 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
52450 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
52451 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
52452 +6 6 6 6 6 6 4 3 3 5 5 5 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
52459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52460 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52461 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52462 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52463 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52464 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52465 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52466 +5 5 5 5 5 5 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
52473 +4 4 4 4 4 4 4 4 4 4 4 4 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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52476 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52477 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52478 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52479 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52480 +4 3 3 5 5 5 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
52487 +4 4 4 4 4 4 4 4 4 4 4 4 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 5 5 5
52490 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52491 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52492 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52493 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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
52501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52504 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52505 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52506 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52507 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52514 +4 4 4 4 4 4
52515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52518 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52519 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52520 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52521 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52528 +4 4 4 4 4 4
52529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52532 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52533 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52534 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52535 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52542 +4 4 4 4 4 4
52543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52547 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52548 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52549 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52556 +4 4 4 4 4 4
52557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52561 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52562 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52563 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52570 +4 4 4 4 4 4
52571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52575 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52576 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52577 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52584 +4 4 4 4 4 4
52585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52589 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52590 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52598 +4 4 4 4 4 4
52599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52603 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52604 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52612 +4 4 4 4 4 4
52613 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52614 index fe92eed..106e085 100644
52615 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52616 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52617 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52618 struct mb862xxfb_par *par = info->par;
52619
52620 if (info->var.bits_per_pixel == 32) {
52621 - info->fbops->fb_fillrect = cfb_fillrect;
52622 - info->fbops->fb_copyarea = cfb_copyarea;
52623 - info->fbops->fb_imageblit = cfb_imageblit;
52624 + pax_open_kernel();
52625 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52626 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52627 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52628 + pax_close_kernel();
52629 } else {
52630 outreg(disp, GC_L0EM, 3);
52631 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52632 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52633 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52634 + pax_open_kernel();
52635 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52636 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52637 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52638 + pax_close_kernel();
52639 }
52640 outreg(draw, GDC_REG_DRAW_BASE, 0);
52641 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52642 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52643 index ff22871..b129bed 100644
52644 --- a/drivers/video/nvidia/nvidia.c
52645 +++ b/drivers/video/nvidia/nvidia.c
52646 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52647 info->fix.line_length = (info->var.xres_virtual *
52648 info->var.bits_per_pixel) >> 3;
52649 if (info->var.accel_flags) {
52650 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52651 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52652 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52653 - info->fbops->fb_sync = nvidiafb_sync;
52654 + pax_open_kernel();
52655 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52656 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52657 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52658 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52659 + pax_close_kernel();
52660 info->pixmap.scan_align = 4;
52661 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52662 info->flags |= FBINFO_READS_FAST;
52663 NVResetGraphics(info);
52664 } else {
52665 - info->fbops->fb_imageblit = cfb_imageblit;
52666 - info->fbops->fb_fillrect = cfb_fillrect;
52667 - info->fbops->fb_copyarea = cfb_copyarea;
52668 - info->fbops->fb_sync = NULL;
52669 + pax_open_kernel();
52670 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52671 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52672 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52673 + *(void **)&info->fbops->fb_sync = NULL;
52674 + pax_close_kernel();
52675 info->pixmap.scan_align = 1;
52676 info->flags |= FBINFO_HWACCEL_DISABLED;
52677 info->flags &= ~FBINFO_READS_FAST;
52678 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52679 info->pixmap.size = 8 * 1024;
52680 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52681
52682 - if (!hwcur)
52683 - info->fbops->fb_cursor = NULL;
52684 + if (!hwcur) {
52685 + pax_open_kernel();
52686 + *(void **)&info->fbops->fb_cursor = NULL;
52687 + pax_close_kernel();
52688 + }
52689
52690 info->var.accel_flags = (!noaccel);
52691
52692 diff --git a/drivers/video/output.c b/drivers/video/output.c
52693 index 0d6f2cd..6285b97 100644
52694 --- a/drivers/video/output.c
52695 +++ b/drivers/video/output.c
52696 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
52697 new_dev->props = op;
52698 new_dev->dev.class = &video_output_class;
52699 new_dev->dev.parent = dev;
52700 - dev_set_name(&new_dev->dev, name);
52701 + dev_set_name(&new_dev->dev, "%s", name);
52702 dev_set_drvdata(&new_dev->dev, devdata);
52703 ret_code = device_register(&new_dev->dev);
52704 if (ret_code) {
52705 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52706 index 05c2dc3..ea1f391 100644
52707 --- a/drivers/video/s1d13xxxfb.c
52708 +++ b/drivers/video/s1d13xxxfb.c
52709 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52710
52711 switch(prod_id) {
52712 case S1D13506_PROD_ID: /* activate acceleration */
52713 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52714 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52715 + pax_open_kernel();
52716 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52717 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52718 + pax_close_kernel();
52719 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52720 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52721 break;
52722 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52723 index b2b33fc..f9f4658 100644
52724 --- a/drivers/video/smscufx.c
52725 +++ b/drivers/video/smscufx.c
52726 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52727 fb_deferred_io_cleanup(info);
52728 kfree(info->fbdefio);
52729 info->fbdefio = NULL;
52730 - info->fbops->fb_mmap = ufx_ops_mmap;
52731 + pax_open_kernel();
52732 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52733 + pax_close_kernel();
52734 }
52735
52736 pr_debug("released /dev/fb%d user=%d count=%d",
52737 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52738 index ec03e72..f578436 100644
52739 --- a/drivers/video/udlfb.c
52740 +++ b/drivers/video/udlfb.c
52741 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52742 dlfb_urb_completion(urb);
52743
52744 error:
52745 - atomic_add(bytes_sent, &dev->bytes_sent);
52746 - atomic_add(bytes_identical, &dev->bytes_identical);
52747 - atomic_add(width*height*2, &dev->bytes_rendered);
52748 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52749 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52750 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52751 end_cycles = get_cycles();
52752 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52753 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52754 >> 10)), /* Kcycles */
52755 &dev->cpu_kcycles_used);
52756
52757 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52758 dlfb_urb_completion(urb);
52759
52760 error:
52761 - atomic_add(bytes_sent, &dev->bytes_sent);
52762 - atomic_add(bytes_identical, &dev->bytes_identical);
52763 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52764 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52765 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52766 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52767 end_cycles = get_cycles();
52768 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52769 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52770 >> 10)), /* Kcycles */
52771 &dev->cpu_kcycles_used);
52772 }
52773 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52774 fb_deferred_io_cleanup(info);
52775 kfree(info->fbdefio);
52776 info->fbdefio = NULL;
52777 - info->fbops->fb_mmap = dlfb_ops_mmap;
52778 + pax_open_kernel();
52779 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52780 + pax_close_kernel();
52781 }
52782
52783 pr_warn("released /dev/fb%d user=%d count=%d\n",
52784 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52785 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52786 struct dlfb_data *dev = fb_info->par;
52787 return snprintf(buf, PAGE_SIZE, "%u\n",
52788 - atomic_read(&dev->bytes_rendered));
52789 + atomic_read_unchecked(&dev->bytes_rendered));
52790 }
52791
52792 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52793 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52794 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52795 struct dlfb_data *dev = fb_info->par;
52796 return snprintf(buf, PAGE_SIZE, "%u\n",
52797 - atomic_read(&dev->bytes_identical));
52798 + atomic_read_unchecked(&dev->bytes_identical));
52799 }
52800
52801 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52802 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52803 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52804 struct dlfb_data *dev = fb_info->par;
52805 return snprintf(buf, PAGE_SIZE, "%u\n",
52806 - atomic_read(&dev->bytes_sent));
52807 + atomic_read_unchecked(&dev->bytes_sent));
52808 }
52809
52810 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52811 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52812 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52813 struct dlfb_data *dev = fb_info->par;
52814 return snprintf(buf, PAGE_SIZE, "%u\n",
52815 - atomic_read(&dev->cpu_kcycles_used));
52816 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52817 }
52818
52819 static ssize_t edid_show(
52820 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52821 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52822 struct dlfb_data *dev = fb_info->par;
52823
52824 - atomic_set(&dev->bytes_rendered, 0);
52825 - atomic_set(&dev->bytes_identical, 0);
52826 - atomic_set(&dev->bytes_sent, 0);
52827 - atomic_set(&dev->cpu_kcycles_used, 0);
52828 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52829 + atomic_set_unchecked(&dev->bytes_identical, 0);
52830 + atomic_set_unchecked(&dev->bytes_sent, 0);
52831 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52832
52833 return count;
52834 }
52835 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52836 index e328a61..1b08ecb 100644
52837 --- a/drivers/video/uvesafb.c
52838 +++ b/drivers/video/uvesafb.c
52839 @@ -19,6 +19,7 @@
52840 #include <linux/io.h>
52841 #include <linux/mutex.h>
52842 #include <linux/slab.h>
52843 +#include <linux/moduleloader.h>
52844 #include <video/edid.h>
52845 #include <video/uvesafb.h>
52846 #ifdef CONFIG_X86
52847 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52848 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52849 par->pmi_setpal = par->ypan = 0;
52850 } else {
52851 +
52852 +#ifdef CONFIG_PAX_KERNEXEC
52853 +#ifdef CONFIG_MODULES
52854 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52855 +#endif
52856 + if (!par->pmi_code) {
52857 + par->pmi_setpal = par->ypan = 0;
52858 + return 0;
52859 + }
52860 +#endif
52861 +
52862 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52863 + task->t.regs.edi);
52864 +
52865 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52866 + pax_open_kernel();
52867 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52868 + pax_close_kernel();
52869 +
52870 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52871 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52872 +#else
52873 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52874 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52875 +#endif
52876 +
52877 printk(KERN_INFO "uvesafb: protected mode interface info at "
52878 "%04x:%04x\n",
52879 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52880 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52881 par->ypan = ypan;
52882
52883 if (par->pmi_setpal || par->ypan) {
52884 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52885 if (__supported_pte_mask & _PAGE_NX) {
52886 par->pmi_setpal = par->ypan = 0;
52887 printk(KERN_WARNING "uvesafb: NX protection is actively."
52888 "We have better not to use the PMI.\n");
52889 - } else {
52890 + } else
52891 +#endif
52892 uvesafb_vbe_getpmi(task, par);
52893 - }
52894 }
52895 #else
52896 /* The protected mode interface is not available on non-x86. */
52897 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52898 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52899
52900 /* Disable blanking if the user requested so. */
52901 - if (!blank)
52902 - info->fbops->fb_blank = NULL;
52903 + if (!blank) {
52904 + pax_open_kernel();
52905 + *(void **)&info->fbops->fb_blank = NULL;
52906 + pax_close_kernel();
52907 + }
52908
52909 /*
52910 * Find out how much IO memory is required for the mode with
52911 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52912 info->flags = FBINFO_FLAG_DEFAULT |
52913 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52914
52915 - if (!par->ypan)
52916 - info->fbops->fb_pan_display = NULL;
52917 + if (!par->ypan) {
52918 + pax_open_kernel();
52919 + *(void **)&info->fbops->fb_pan_display = NULL;
52920 + pax_close_kernel();
52921 + }
52922 }
52923
52924 static void uvesafb_init_mtrr(struct fb_info *info)
52925 @@ -1836,6 +1866,11 @@ out:
52926 if (par->vbe_modes)
52927 kfree(par->vbe_modes);
52928
52929 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52930 + if (par->pmi_code)
52931 + module_free_exec(NULL, par->pmi_code);
52932 +#endif
52933 +
52934 framebuffer_release(info);
52935 return err;
52936 }
52937 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
52938 kfree(par->vbe_state_orig);
52939 if (par->vbe_state_saved)
52940 kfree(par->vbe_state_saved);
52941 +
52942 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52943 + if (par->pmi_code)
52944 + module_free_exec(NULL, par->pmi_code);
52945 +#endif
52946 +
52947 }
52948
52949 framebuffer_release(info);
52950 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52951 index 501b340..d80aa17 100644
52952 --- a/drivers/video/vesafb.c
52953 +++ b/drivers/video/vesafb.c
52954 @@ -9,6 +9,7 @@
52955 */
52956
52957 #include <linux/module.h>
52958 +#include <linux/moduleloader.h>
52959 #include <linux/kernel.h>
52960 #include <linux/errno.h>
52961 #include <linux/string.h>
52962 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
52963 static int vram_total __initdata; /* Set total amount of memory */
52964 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52965 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52966 -static void (*pmi_start)(void) __read_mostly;
52967 -static void (*pmi_pal) (void) __read_mostly;
52968 +static void (*pmi_start)(void) __read_only;
52969 +static void (*pmi_pal) (void) __read_only;
52970 static int depth __read_mostly;
52971 static int vga_compat __read_mostly;
52972 /* --------------------------------------------------------------------- */
52973 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
52974 unsigned int size_vmode;
52975 unsigned int size_remap;
52976 unsigned int size_total;
52977 + void *pmi_code = NULL;
52978
52979 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
52980 return -ENODEV;
52981 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
52982 size_remap = size_total;
52983 vesafb_fix.smem_len = size_remap;
52984
52985 -#ifndef __i386__
52986 - screen_info.vesapm_seg = 0;
52987 -#endif
52988 -
52989 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52990 printk(KERN_WARNING
52991 "vesafb: cannot reserve video memory at 0x%lx\n",
52992 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
52993 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52994 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52995
52996 +#ifdef __i386__
52997 +
52998 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52999 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
53000 + if (!pmi_code)
53001 +#elif !defined(CONFIG_PAX_KERNEXEC)
53002 + if (0)
53003 +#endif
53004 +
53005 +#endif
53006 + screen_info.vesapm_seg = 0;
53007 +
53008 if (screen_info.vesapm_seg) {
53009 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
53010 - screen_info.vesapm_seg,screen_info.vesapm_off);
53011 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
53012 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
53013 }
53014
53015 if (screen_info.vesapm_seg < 0xc000)
53016 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
53017
53018 if (ypan || pmi_setpal) {
53019 unsigned short *pmi_base;
53020 +
53021 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
53022 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
53023 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
53024 +
53025 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53026 + pax_open_kernel();
53027 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
53028 +#else
53029 + pmi_code = pmi_base;
53030 +#endif
53031 +
53032 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
53033 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
53034 +
53035 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53036 + pmi_start = ktva_ktla(pmi_start);
53037 + pmi_pal = ktva_ktla(pmi_pal);
53038 + pax_close_kernel();
53039 +#endif
53040 +
53041 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
53042 if (pmi_base[3]) {
53043 printk(KERN_INFO "vesafb: pmi: ports = ");
53044 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
53045 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
53046 (ypan ? FBINFO_HWACCEL_YPAN : 0);
53047
53048 - if (!ypan)
53049 - info->fbops->fb_pan_display = NULL;
53050 + if (!ypan) {
53051 + pax_open_kernel();
53052 + *(void **)&info->fbops->fb_pan_display = NULL;
53053 + pax_close_kernel();
53054 + }
53055
53056 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
53057 err = -ENOMEM;
53058 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
53059 info->node, info->fix.id);
53060 return 0;
53061 err:
53062 +
53063 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53064 + module_free_exec(NULL, pmi_code);
53065 +#endif
53066 +
53067 if (info->screen_base)
53068 iounmap(info->screen_base);
53069 framebuffer_release(info);
53070 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
53071 index 88714ae..16c2e11 100644
53072 --- a/drivers/video/via/via_clock.h
53073 +++ b/drivers/video/via/via_clock.h
53074 @@ -56,7 +56,7 @@ struct via_clock {
53075
53076 void (*set_engine_pll_state)(u8 state);
53077 void (*set_engine_pll)(struct via_pll_config config);
53078 -};
53079 +} __no_const;
53080
53081
53082 static inline u32 get_pll_internal_frequency(u32 ref_freq,
53083 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
53084 index fef20db..d28b1ab 100644
53085 --- a/drivers/xen/xenfs/xenstored.c
53086 +++ b/drivers/xen/xenfs/xenstored.c
53087 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
53088 static int xsd_kva_open(struct inode *inode, struct file *file)
53089 {
53090 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
53091 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53092 + NULL);
53093 +#else
53094 xen_store_interface);
53095 +#endif
53096 +
53097 if (!file->private_data)
53098 return -ENOMEM;
53099 return 0;
53100 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
53101 index 055562c..fdfb10d 100644
53102 --- a/fs/9p/vfs_addr.c
53103 +++ b/fs/9p/vfs_addr.c
53104 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
53105
53106 retval = v9fs_file_write_internal(inode,
53107 v9inode->writeback_fid,
53108 - (__force const char __user *)buffer,
53109 + (const char __force_user *)buffer,
53110 len, &offset, 0);
53111 if (retval > 0)
53112 retval = 0;
53113 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
53114 index d86edc8..40ff2fb 100644
53115 --- a/fs/9p/vfs_inode.c
53116 +++ b/fs/9p/vfs_inode.c
53117 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
53118 void
53119 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53120 {
53121 - char *s = nd_get_link(nd);
53122 + const char *s = nd_get_link(nd);
53123
53124 p9_debug(P9_DEBUG_VFS, " %s %s\n",
53125 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
53126 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
53127 index 370b24c..ff0be7b 100644
53128 --- a/fs/Kconfig.binfmt
53129 +++ b/fs/Kconfig.binfmt
53130 @@ -103,7 +103,7 @@ config HAVE_AOUT
53131
53132 config BINFMT_AOUT
53133 tristate "Kernel support for a.out and ECOFF binaries"
53134 - depends on HAVE_AOUT
53135 + depends on HAVE_AOUT && BROKEN
53136 ---help---
53137 A.out (Assembler.OUTput) is a set of formats for libraries and
53138 executables used in the earliest versions of UNIX. Linux used
53139 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
53140 index 789bc25..fafaeea 100644
53141 --- a/fs/afs/inode.c
53142 +++ b/fs/afs/inode.c
53143 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53144 struct afs_vnode *vnode;
53145 struct super_block *sb;
53146 struct inode *inode;
53147 - static atomic_t afs_autocell_ino;
53148 + static atomic_unchecked_t afs_autocell_ino;
53149
53150 _enter("{%x:%u},%*.*s,",
53151 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
53152 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53153 data.fid.unique = 0;
53154 data.fid.vnode = 0;
53155
53156 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
53157 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
53158 afs_iget5_autocell_test, afs_iget5_set,
53159 &data);
53160 if (!inode) {
53161 diff --git a/fs/aio.c b/fs/aio.c
53162 index 2bbcacf..8614116 100644
53163 --- a/fs/aio.c
53164 +++ b/fs/aio.c
53165 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
53166 size += sizeof(struct io_event) * nr_events;
53167 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
53168
53169 - if (nr_pages < 0)
53170 + if (nr_pages <= 0)
53171 return -EINVAL;
53172
53173 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
53174 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
53175 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
53176 {
53177 ssize_t ret;
53178 + struct iovec iovstack;
53179
53180 kiocb->ki_nr_segs = kiocb->ki_nbytes;
53181
53182 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
53183 if (compat)
53184 ret = compat_rw_copy_check_uvector(rw,
53185 (struct compat_iovec __user *)kiocb->ki_buf,
53186 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
53187 + kiocb->ki_nr_segs, 1, &iovstack,
53188 &kiocb->ki_iovec);
53189 else
53190 #endif
53191 ret = rw_copy_check_uvector(rw,
53192 (struct iovec __user *)kiocb->ki_buf,
53193 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
53194 + kiocb->ki_nr_segs, 1, &iovstack,
53195 &kiocb->ki_iovec);
53196 if (ret < 0)
53197 return ret;
53198
53199 + if (kiocb->ki_iovec == &iovstack) {
53200 + kiocb->ki_inline_vec = iovstack;
53201 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
53202 + }
53203 +
53204 /* ki_nbytes now reflect bytes instead of segs */
53205 kiocb->ki_nbytes = ret;
53206 return 0;
53207 diff --git a/fs/attr.c b/fs/attr.c
53208 index 1449adb..a2038c2 100644
53209 --- a/fs/attr.c
53210 +++ b/fs/attr.c
53211 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
53212 unsigned long limit;
53213
53214 limit = rlimit(RLIMIT_FSIZE);
53215 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
53216 if (limit != RLIM_INFINITY && offset > limit)
53217 goto out_sig;
53218 if (offset > inode->i_sb->s_maxbytes)
53219 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
53220 index 3db70da..7aeec5b 100644
53221 --- a/fs/autofs4/waitq.c
53222 +++ b/fs/autofs4/waitq.c
53223 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
53224 {
53225 unsigned long sigpipe, flags;
53226 mm_segment_t fs;
53227 - const char *data = (const char *)addr;
53228 + const char __user *data = (const char __force_user *)addr;
53229 ssize_t wr = 0;
53230
53231 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
53232 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
53233 return 1;
53234 }
53235
53236 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53237 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
53238 +#endif
53239 +
53240 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53241 enum autofs_notify notify)
53242 {
53243 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53244
53245 /* If this is a direct mount request create a dummy name */
53246 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
53247 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53248 + /* this name does get written to userland via autofs4_write() */
53249 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
53250 +#else
53251 qstr.len = sprintf(name, "%p", dentry);
53252 +#endif
53253 else {
53254 qstr.len = autofs4_getpath(sbi, dentry, &name);
53255 if (!qstr.len) {
53256 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
53257 index 2722387..c8dd2a7 100644
53258 --- a/fs/befs/endian.h
53259 +++ b/fs/befs/endian.h
53260 @@ -11,7 +11,7 @@
53261
53262 #include <asm/byteorder.h>
53263
53264 -static inline u64
53265 +static inline u64 __intentional_overflow(-1)
53266 fs64_to_cpu(const struct super_block *sb, fs64 n)
53267 {
53268 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53269 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
53270 return (__force fs64)cpu_to_be64(n);
53271 }
53272
53273 -static inline u32
53274 +static inline u32 __intentional_overflow(-1)
53275 fs32_to_cpu(const struct super_block *sb, fs32 n)
53276 {
53277 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53278 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
53279 index f95dddc..b1e2c1c 100644
53280 --- a/fs/befs/linuxvfs.c
53281 +++ b/fs/befs/linuxvfs.c
53282 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53283 {
53284 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
53285 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
53286 - char *link = nd_get_link(nd);
53287 + const char *link = nd_get_link(nd);
53288 if (!IS_ERR(link))
53289 kfree(link);
53290 }
53291 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
53292 index bce8769..7fc7544 100644
53293 --- a/fs/binfmt_aout.c
53294 +++ b/fs/binfmt_aout.c
53295 @@ -16,6 +16,7 @@
53296 #include <linux/string.h>
53297 #include <linux/fs.h>
53298 #include <linux/file.h>
53299 +#include <linux/security.h>
53300 #include <linux/stat.h>
53301 #include <linux/fcntl.h>
53302 #include <linux/ptrace.h>
53303 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
53304 #endif
53305 # define START_STACK(u) ((void __user *)u.start_stack)
53306
53307 + memset(&dump, 0, sizeof(dump));
53308 +
53309 fs = get_fs();
53310 set_fs(KERNEL_DS);
53311 has_dumped = 1;
53312 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
53313
53314 /* If the size of the dump file exceeds the rlimit, then see what would happen
53315 if we wrote the stack, but not the data area. */
53316 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
53317 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
53318 dump.u_dsize = 0;
53319
53320 /* Make sure we have enough room to write the stack and data areas. */
53321 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
53322 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
53323 dump.u_ssize = 0;
53324
53325 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
53326 rlim = rlimit(RLIMIT_DATA);
53327 if (rlim >= RLIM_INFINITY)
53328 rlim = ~0;
53329 +
53330 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
53331 if (ex.a_data + ex.a_bss > rlim)
53332 return -ENOMEM;
53333
53334 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
53335
53336 install_exec_creds(bprm);
53337
53338 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53339 + current->mm->pax_flags = 0UL;
53340 +#endif
53341 +
53342 +#ifdef CONFIG_PAX_PAGEEXEC
53343 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
53344 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
53345 +
53346 +#ifdef CONFIG_PAX_EMUTRAMP
53347 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
53348 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
53349 +#endif
53350 +
53351 +#ifdef CONFIG_PAX_MPROTECT
53352 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
53353 + current->mm->pax_flags |= MF_PAX_MPROTECT;
53354 +#endif
53355 +
53356 + }
53357 +#endif
53358 +
53359 if (N_MAGIC(ex) == OMAGIC) {
53360 unsigned long text_addr, map_size;
53361 loff_t pos;
53362 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
53363 }
53364
53365 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
53366 - PROT_READ | PROT_WRITE | PROT_EXEC,
53367 + PROT_READ | PROT_WRITE,
53368 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
53369 fd_offset + ex.a_text);
53370 if (error != N_DATADDR(ex)) {
53371 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
53372 index f8a0b0e..6f036ed 100644
53373 --- a/fs/binfmt_elf.c
53374 +++ b/fs/binfmt_elf.c
53375 @@ -34,6 +34,7 @@
53376 #include <linux/utsname.h>
53377 #include <linux/coredump.h>
53378 #include <linux/sched.h>
53379 +#include <linux/xattr.h>
53380 #include <asm/uaccess.h>
53381 #include <asm/param.h>
53382 #include <asm/page.h>
53383 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
53384 #define elf_core_dump NULL
53385 #endif
53386
53387 +#ifdef CONFIG_PAX_MPROTECT
53388 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
53389 +#endif
53390 +
53391 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53392 +static void elf_handle_mmap(struct file *file);
53393 +#endif
53394 +
53395 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
53396 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
53397 #else
53398 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
53399 .load_binary = load_elf_binary,
53400 .load_shlib = load_elf_library,
53401 .core_dump = elf_core_dump,
53402 +
53403 +#ifdef CONFIG_PAX_MPROTECT
53404 + .handle_mprotect= elf_handle_mprotect,
53405 +#endif
53406 +
53407 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53408 + .handle_mmap = elf_handle_mmap,
53409 +#endif
53410 +
53411 .min_coredump = ELF_EXEC_PAGESIZE,
53412 };
53413
53414 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
53415
53416 static int set_brk(unsigned long start, unsigned long end)
53417 {
53418 + unsigned long e = end;
53419 +
53420 start = ELF_PAGEALIGN(start);
53421 end = ELF_PAGEALIGN(end);
53422 if (end > start) {
53423 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
53424 if (BAD_ADDR(addr))
53425 return addr;
53426 }
53427 - current->mm->start_brk = current->mm->brk = end;
53428 + current->mm->start_brk = current->mm->brk = e;
53429 return 0;
53430 }
53431
53432 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53433 elf_addr_t __user *u_rand_bytes;
53434 const char *k_platform = ELF_PLATFORM;
53435 const char *k_base_platform = ELF_BASE_PLATFORM;
53436 - unsigned char k_rand_bytes[16];
53437 + u32 k_rand_bytes[4];
53438 int items;
53439 elf_addr_t *elf_info;
53440 int ei_index = 0;
53441 const struct cred *cred = current_cred();
53442 struct vm_area_struct *vma;
53443 + unsigned long saved_auxv[AT_VECTOR_SIZE];
53444
53445 /*
53446 * In some cases (e.g. Hyper-Threading), we want to avoid L1
53447 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53448 * Generate 16 random bytes for userspace PRNG seeding.
53449 */
53450 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
53451 - u_rand_bytes = (elf_addr_t __user *)
53452 - STACK_ALLOC(p, sizeof(k_rand_bytes));
53453 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
53454 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
53455 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
53456 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
53457 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
53458 + u_rand_bytes = (elf_addr_t __user *) p;
53459 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
53460 return -EFAULT;
53461
53462 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53463 return -EFAULT;
53464 current->mm->env_end = p;
53465
53466 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
53467 +
53468 /* Put the elf_info on the stack in the right place. */
53469 sp = (elf_addr_t __user *)envp + 1;
53470 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53471 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53472 return -EFAULT;
53473 return 0;
53474 }
53475 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53476 an ELF header */
53477
53478 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53479 - struct file *interpreter, unsigned long *interp_map_addr,
53480 - unsigned long no_base)
53481 + struct file *interpreter, unsigned long no_base)
53482 {
53483 struct elf_phdr *elf_phdata;
53484 struct elf_phdr *eppnt;
53485 - unsigned long load_addr = 0;
53486 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53487 int load_addr_set = 0;
53488 unsigned long last_bss = 0, elf_bss = 0;
53489 - unsigned long error = ~0UL;
53490 + unsigned long error = -EINVAL;
53491 unsigned long total_size;
53492 int retval, i, size;
53493
53494 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53495 goto out_close;
53496 }
53497
53498 +#ifdef CONFIG_PAX_SEGMEXEC
53499 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53500 + pax_task_size = SEGMEXEC_TASK_SIZE;
53501 +#endif
53502 +
53503 eppnt = elf_phdata;
53504 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53505 if (eppnt->p_type == PT_LOAD) {
53506 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53507 map_addr = elf_map(interpreter, load_addr + vaddr,
53508 eppnt, elf_prot, elf_type, total_size);
53509 total_size = 0;
53510 - if (!*interp_map_addr)
53511 - *interp_map_addr = map_addr;
53512 error = map_addr;
53513 if (BAD_ADDR(map_addr))
53514 goto out_close;
53515 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53516 k = load_addr + eppnt->p_vaddr;
53517 if (BAD_ADDR(k) ||
53518 eppnt->p_filesz > eppnt->p_memsz ||
53519 - eppnt->p_memsz > TASK_SIZE ||
53520 - TASK_SIZE - eppnt->p_memsz < k) {
53521 + eppnt->p_memsz > pax_task_size ||
53522 + pax_task_size - eppnt->p_memsz < k) {
53523 error = -ENOMEM;
53524 goto out_close;
53525 }
53526 @@ -538,6 +567,315 @@ out:
53527 return error;
53528 }
53529
53530 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53531 +#ifdef CONFIG_PAX_SOFTMODE
53532 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53533 +{
53534 + unsigned long pax_flags = 0UL;
53535 +
53536 +#ifdef CONFIG_PAX_PAGEEXEC
53537 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53538 + pax_flags |= MF_PAX_PAGEEXEC;
53539 +#endif
53540 +
53541 +#ifdef CONFIG_PAX_SEGMEXEC
53542 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53543 + pax_flags |= MF_PAX_SEGMEXEC;
53544 +#endif
53545 +
53546 +#ifdef CONFIG_PAX_EMUTRAMP
53547 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53548 + pax_flags |= MF_PAX_EMUTRAMP;
53549 +#endif
53550 +
53551 +#ifdef CONFIG_PAX_MPROTECT
53552 + if (elf_phdata->p_flags & PF_MPROTECT)
53553 + pax_flags |= MF_PAX_MPROTECT;
53554 +#endif
53555 +
53556 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53557 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53558 + pax_flags |= MF_PAX_RANDMMAP;
53559 +#endif
53560 +
53561 + return pax_flags;
53562 +}
53563 +#endif
53564 +
53565 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53566 +{
53567 + unsigned long pax_flags = 0UL;
53568 +
53569 +#ifdef CONFIG_PAX_PAGEEXEC
53570 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53571 + pax_flags |= MF_PAX_PAGEEXEC;
53572 +#endif
53573 +
53574 +#ifdef CONFIG_PAX_SEGMEXEC
53575 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53576 + pax_flags |= MF_PAX_SEGMEXEC;
53577 +#endif
53578 +
53579 +#ifdef CONFIG_PAX_EMUTRAMP
53580 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53581 + pax_flags |= MF_PAX_EMUTRAMP;
53582 +#endif
53583 +
53584 +#ifdef CONFIG_PAX_MPROTECT
53585 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53586 + pax_flags |= MF_PAX_MPROTECT;
53587 +#endif
53588 +
53589 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53590 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53591 + pax_flags |= MF_PAX_RANDMMAP;
53592 +#endif
53593 +
53594 + return pax_flags;
53595 +}
53596 +#endif
53597 +
53598 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53599 +#ifdef CONFIG_PAX_SOFTMODE
53600 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53601 +{
53602 + unsigned long pax_flags = 0UL;
53603 +
53604 +#ifdef CONFIG_PAX_PAGEEXEC
53605 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53606 + pax_flags |= MF_PAX_PAGEEXEC;
53607 +#endif
53608 +
53609 +#ifdef CONFIG_PAX_SEGMEXEC
53610 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53611 + pax_flags |= MF_PAX_SEGMEXEC;
53612 +#endif
53613 +
53614 +#ifdef CONFIG_PAX_EMUTRAMP
53615 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53616 + pax_flags |= MF_PAX_EMUTRAMP;
53617 +#endif
53618 +
53619 +#ifdef CONFIG_PAX_MPROTECT
53620 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53621 + pax_flags |= MF_PAX_MPROTECT;
53622 +#endif
53623 +
53624 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53625 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53626 + pax_flags |= MF_PAX_RANDMMAP;
53627 +#endif
53628 +
53629 + return pax_flags;
53630 +}
53631 +#endif
53632 +
53633 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53634 +{
53635 + unsigned long pax_flags = 0UL;
53636 +
53637 +#ifdef CONFIG_PAX_PAGEEXEC
53638 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53639 + pax_flags |= MF_PAX_PAGEEXEC;
53640 +#endif
53641 +
53642 +#ifdef CONFIG_PAX_SEGMEXEC
53643 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53644 + pax_flags |= MF_PAX_SEGMEXEC;
53645 +#endif
53646 +
53647 +#ifdef CONFIG_PAX_EMUTRAMP
53648 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53649 + pax_flags |= MF_PAX_EMUTRAMP;
53650 +#endif
53651 +
53652 +#ifdef CONFIG_PAX_MPROTECT
53653 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53654 + pax_flags |= MF_PAX_MPROTECT;
53655 +#endif
53656 +
53657 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53658 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53659 + pax_flags |= MF_PAX_RANDMMAP;
53660 +#endif
53661 +
53662 + return pax_flags;
53663 +}
53664 +#endif
53665 +
53666 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53667 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53668 +{
53669 + unsigned long pax_flags = 0UL;
53670 +
53671 +#ifdef CONFIG_PAX_EI_PAX
53672 +
53673 +#ifdef CONFIG_PAX_PAGEEXEC
53674 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53675 + pax_flags |= MF_PAX_PAGEEXEC;
53676 +#endif
53677 +
53678 +#ifdef CONFIG_PAX_SEGMEXEC
53679 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53680 + pax_flags |= MF_PAX_SEGMEXEC;
53681 +#endif
53682 +
53683 +#ifdef CONFIG_PAX_EMUTRAMP
53684 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53685 + pax_flags |= MF_PAX_EMUTRAMP;
53686 +#endif
53687 +
53688 +#ifdef CONFIG_PAX_MPROTECT
53689 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53690 + pax_flags |= MF_PAX_MPROTECT;
53691 +#endif
53692 +
53693 +#ifdef CONFIG_PAX_ASLR
53694 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53695 + pax_flags |= MF_PAX_RANDMMAP;
53696 +#endif
53697 +
53698 +#else
53699 +
53700 +#ifdef CONFIG_PAX_PAGEEXEC
53701 + pax_flags |= MF_PAX_PAGEEXEC;
53702 +#endif
53703 +
53704 +#ifdef CONFIG_PAX_SEGMEXEC
53705 + pax_flags |= MF_PAX_SEGMEXEC;
53706 +#endif
53707 +
53708 +#ifdef CONFIG_PAX_MPROTECT
53709 + pax_flags |= MF_PAX_MPROTECT;
53710 +#endif
53711 +
53712 +#ifdef CONFIG_PAX_RANDMMAP
53713 + if (randomize_va_space)
53714 + pax_flags |= MF_PAX_RANDMMAP;
53715 +#endif
53716 +
53717 +#endif
53718 +
53719 + return pax_flags;
53720 +}
53721 +
53722 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53723 +{
53724 +
53725 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53726 + unsigned long i;
53727 +
53728 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53729 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53730 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53731 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53732 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53733 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53734 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53735 + return ~0UL;
53736 +
53737 +#ifdef CONFIG_PAX_SOFTMODE
53738 + if (pax_softmode)
53739 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53740 + else
53741 +#endif
53742 +
53743 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53744 + break;
53745 + }
53746 +#endif
53747 +
53748 + return ~0UL;
53749 +}
53750 +
53751 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53752 +{
53753 +
53754 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53755 + ssize_t xattr_size, i;
53756 + unsigned char xattr_value[sizeof("pemrs") - 1];
53757 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53758 +
53759 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53760 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53761 + return ~0UL;
53762 +
53763 + for (i = 0; i < xattr_size; i++)
53764 + switch (xattr_value[i]) {
53765 + default:
53766 + return ~0UL;
53767 +
53768 +#define parse_flag(option1, option2, flag) \
53769 + case option1: \
53770 + if (pax_flags_hardmode & MF_PAX_##flag) \
53771 + return ~0UL; \
53772 + pax_flags_hardmode |= MF_PAX_##flag; \
53773 + break; \
53774 + case option2: \
53775 + if (pax_flags_softmode & MF_PAX_##flag) \
53776 + return ~0UL; \
53777 + pax_flags_softmode |= MF_PAX_##flag; \
53778 + break;
53779 +
53780 + parse_flag('p', 'P', PAGEEXEC);
53781 + parse_flag('e', 'E', EMUTRAMP);
53782 + parse_flag('m', 'M', MPROTECT);
53783 + parse_flag('r', 'R', RANDMMAP);
53784 + parse_flag('s', 'S', SEGMEXEC);
53785 +
53786 +#undef parse_flag
53787 + }
53788 +
53789 + if (pax_flags_hardmode & pax_flags_softmode)
53790 + return ~0UL;
53791 +
53792 +#ifdef CONFIG_PAX_SOFTMODE
53793 + if (pax_softmode)
53794 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53795 + else
53796 +#endif
53797 +
53798 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53799 +#else
53800 + return ~0UL;
53801 +#endif
53802 +
53803 +}
53804 +
53805 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53806 +{
53807 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53808 +
53809 + pax_flags = pax_parse_ei_pax(elf_ex);
53810 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53811 + xattr_pax_flags = pax_parse_xattr_pax(file);
53812 +
53813 + if (pt_pax_flags == ~0UL)
53814 + pt_pax_flags = xattr_pax_flags;
53815 + else if (xattr_pax_flags == ~0UL)
53816 + xattr_pax_flags = pt_pax_flags;
53817 + if (pt_pax_flags != xattr_pax_flags)
53818 + return -EINVAL;
53819 + if (pt_pax_flags != ~0UL)
53820 + pax_flags = pt_pax_flags;
53821 +
53822 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53823 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53824 + if ((__supported_pte_mask & _PAGE_NX))
53825 + pax_flags &= ~MF_PAX_SEGMEXEC;
53826 + else
53827 + pax_flags &= ~MF_PAX_PAGEEXEC;
53828 + }
53829 +#endif
53830 +
53831 + if (0 > pax_check_flags(&pax_flags))
53832 + return -EINVAL;
53833 +
53834 + current->mm->pax_flags = pax_flags;
53835 + return 0;
53836 +}
53837 +#endif
53838 +
53839 /*
53840 * These are the functions used to load ELF style executables and shared
53841 * libraries. There is no binary dependent code anywhere else.
53842 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53843 {
53844 unsigned int random_variable = 0;
53845
53846 +#ifdef CONFIG_PAX_RANDUSTACK
53847 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53848 + return stack_top - current->mm->delta_stack;
53849 +#endif
53850 +
53851 if ((current->flags & PF_RANDOMIZE) &&
53852 !(current->personality & ADDR_NO_RANDOMIZE)) {
53853 random_variable = get_random_int() & STACK_RND_MASK;
53854 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53855 unsigned long load_addr = 0, load_bias = 0;
53856 int load_addr_set = 0;
53857 char * elf_interpreter = NULL;
53858 - unsigned long error;
53859 + unsigned long error = 0;
53860 struct elf_phdr *elf_ppnt, *elf_phdata;
53861 unsigned long elf_bss, elf_brk;
53862 int retval, i;
53863 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53864 unsigned long start_code, end_code, start_data, end_data;
53865 unsigned long reloc_func_desc __maybe_unused = 0;
53866 int executable_stack = EXSTACK_DEFAULT;
53867 - unsigned long def_flags = 0;
53868 struct pt_regs *regs = current_pt_regs();
53869 struct {
53870 struct elfhdr elf_ex;
53871 struct elfhdr interp_elf_ex;
53872 } *loc;
53873 + unsigned long pax_task_size = TASK_SIZE;
53874
53875 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53876 if (!loc) {
53877 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
53878 goto out_free_dentry;
53879
53880 /* OK, This is the point of no return */
53881 - current->mm->def_flags = def_flags;
53882 +
53883 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53884 + current->mm->pax_flags = 0UL;
53885 +#endif
53886 +
53887 +#ifdef CONFIG_PAX_DLRESOLVE
53888 + current->mm->call_dl_resolve = 0UL;
53889 +#endif
53890 +
53891 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53892 + current->mm->call_syscall = 0UL;
53893 +#endif
53894 +
53895 +#ifdef CONFIG_PAX_ASLR
53896 + current->mm->delta_mmap = 0UL;
53897 + current->mm->delta_stack = 0UL;
53898 +#endif
53899 +
53900 + current->mm->def_flags = 0;
53901 +
53902 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53903 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53904 + send_sig(SIGKILL, current, 0);
53905 + goto out_free_dentry;
53906 + }
53907 +#endif
53908 +
53909 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53910 + pax_set_initial_flags(bprm);
53911 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53912 + if (pax_set_initial_flags_func)
53913 + (pax_set_initial_flags_func)(bprm);
53914 +#endif
53915 +
53916 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53917 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53918 + current->mm->context.user_cs_limit = PAGE_SIZE;
53919 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53920 + }
53921 +#endif
53922 +
53923 +#ifdef CONFIG_PAX_SEGMEXEC
53924 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53925 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53926 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53927 + pax_task_size = SEGMEXEC_TASK_SIZE;
53928 + current->mm->def_flags |= VM_NOHUGEPAGE;
53929 + }
53930 +#endif
53931 +
53932 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53933 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53934 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53935 + put_cpu();
53936 + }
53937 +#endif
53938
53939 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53940 may depend on the personality. */
53941 SET_PERSONALITY(loc->elf_ex);
53942 +
53943 +#ifdef CONFIG_PAX_ASLR
53944 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53945 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53946 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53947 + }
53948 +#endif
53949 +
53950 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53951 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53952 + executable_stack = EXSTACK_DISABLE_X;
53953 + current->personality &= ~READ_IMPLIES_EXEC;
53954 + } else
53955 +#endif
53956 +
53957 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53958 current->personality |= READ_IMPLIES_EXEC;
53959
53960 @@ -819,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53961 #else
53962 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53963 #endif
53964 +
53965 +#ifdef CONFIG_PAX_RANDMMAP
53966 + /* PaX: randomize base address at the default exe base if requested */
53967 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53968 +#ifdef CONFIG_SPARC64
53969 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53970 +#else
53971 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53972 +#endif
53973 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53974 + elf_flags |= MAP_FIXED;
53975 + }
53976 +#endif
53977 +
53978 }
53979
53980 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53981 @@ -851,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53982 * allowed task size. Note that p_filesz must always be
53983 * <= p_memsz so it is only necessary to check p_memsz.
53984 */
53985 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53986 - elf_ppnt->p_memsz > TASK_SIZE ||
53987 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53988 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53989 + elf_ppnt->p_memsz > pax_task_size ||
53990 + pax_task_size - elf_ppnt->p_memsz < k) {
53991 /* set_brk can never work. Avoid overflows. */
53992 send_sig(SIGKILL, current, 0);
53993 retval = -EINVAL;
53994 @@ -892,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53995 goto out_free_dentry;
53996 }
53997 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53998 - send_sig(SIGSEGV, current, 0);
53999 - retval = -EFAULT; /* Nobody gets to see this, but.. */
54000 - goto out_free_dentry;
54001 + /*
54002 + * This bss-zeroing can fail if the ELF
54003 + * file specifies odd protections. So
54004 + * we don't check the return value
54005 + */
54006 }
54007
54008 +#ifdef CONFIG_PAX_RANDMMAP
54009 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54010 + unsigned long start, size, flags;
54011 + vm_flags_t vm_flags;
54012 +
54013 + start = ELF_PAGEALIGN(elf_brk);
54014 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
54015 + flags = MAP_FIXED | MAP_PRIVATE;
54016 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
54017 +
54018 + down_write(&current->mm->mmap_sem);
54019 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
54020 + retval = -ENOMEM;
54021 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
54022 +// if (current->personality & ADDR_NO_RANDOMIZE)
54023 +// vm_flags |= VM_READ | VM_MAYREAD;
54024 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
54025 + retval = IS_ERR_VALUE(start) ? start : 0;
54026 + }
54027 + up_write(&current->mm->mmap_sem);
54028 + if (retval == 0)
54029 + retval = set_brk(start + size, start + size + PAGE_SIZE);
54030 + if (retval < 0) {
54031 + send_sig(SIGKILL, current, 0);
54032 + goto out_free_dentry;
54033 + }
54034 + }
54035 +#endif
54036 +
54037 if (elf_interpreter) {
54038 - unsigned long interp_map_addr = 0;
54039 -
54040 elf_entry = load_elf_interp(&loc->interp_elf_ex,
54041 interpreter,
54042 - &interp_map_addr,
54043 load_bias);
54044 if (!IS_ERR((void *)elf_entry)) {
54045 /*
54046 @@ -1124,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
54047 * Decide what to dump of a segment, part, all or none.
54048 */
54049 static unsigned long vma_dump_size(struct vm_area_struct *vma,
54050 - unsigned long mm_flags)
54051 + unsigned long mm_flags, long signr)
54052 {
54053 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
54054
54055 @@ -1162,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
54056 if (vma->vm_file == NULL)
54057 return 0;
54058
54059 - if (FILTER(MAPPED_PRIVATE))
54060 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
54061 goto whole;
54062
54063 /*
54064 @@ -1387,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
54065 {
54066 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
54067 int i = 0;
54068 - do
54069 + do {
54070 i += 2;
54071 - while (auxv[i - 2] != AT_NULL);
54072 + } while (auxv[i - 2] != AT_NULL);
54073 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
54074 }
54075
54076 @@ -1398,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
54077 {
54078 mm_segment_t old_fs = get_fs();
54079 set_fs(KERNEL_DS);
54080 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
54081 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
54082 set_fs(old_fs);
54083 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
54084 }
54085 @@ -2019,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
54086 }
54087
54088 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
54089 - unsigned long mm_flags)
54090 + struct coredump_params *cprm)
54091 {
54092 struct vm_area_struct *vma;
54093 size_t size = 0;
54094
54095 for (vma = first_vma(current, gate_vma); vma != NULL;
54096 vma = next_vma(vma, gate_vma))
54097 - size += vma_dump_size(vma, mm_flags);
54098 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54099 return size;
54100 }
54101
54102 @@ -2119,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54103
54104 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
54105
54106 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
54107 + offset += elf_core_vma_data_size(gate_vma, cprm);
54108 offset += elf_core_extra_data_size();
54109 e_shoff = offset;
54110
54111 @@ -2133,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
54112 offset = dataoff;
54113
54114 size += sizeof(*elf);
54115 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54116 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
54117 goto end_coredump;
54118
54119 size += sizeof(*phdr4note);
54120 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54121 if (size > cprm->limit
54122 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
54123 goto end_coredump;
54124 @@ -2150,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54125 phdr.p_offset = offset;
54126 phdr.p_vaddr = vma->vm_start;
54127 phdr.p_paddr = 0;
54128 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
54129 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54130 phdr.p_memsz = vma->vm_end - vma->vm_start;
54131 offset += phdr.p_filesz;
54132 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
54133 @@ -2161,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54134 phdr.p_align = ELF_EXEC_PAGESIZE;
54135
54136 size += sizeof(phdr);
54137 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54138 if (size > cprm->limit
54139 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
54140 goto end_coredump;
54141 @@ -2185,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54142 unsigned long addr;
54143 unsigned long end;
54144
54145 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
54146 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54147
54148 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
54149 struct page *page;
54150 @@ -2194,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54151 page = get_dump_page(addr);
54152 if (page) {
54153 void *kaddr = kmap(page);
54154 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
54155 stop = ((size += PAGE_SIZE) > cprm->limit) ||
54156 !dump_write(cprm->file, kaddr,
54157 PAGE_SIZE);
54158 @@ -2211,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54159
54160 if (e_phnum == PN_XNUM) {
54161 size += sizeof(*shdr4extnum);
54162 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54163 if (size > cprm->limit
54164 || !dump_write(cprm->file, shdr4extnum,
54165 sizeof(*shdr4extnum)))
54166 @@ -2231,6 +2691,167 @@ out:
54167
54168 #endif /* CONFIG_ELF_CORE */
54169
54170 +#ifdef CONFIG_PAX_MPROTECT
54171 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
54172 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
54173 + * we'll remove VM_MAYWRITE for good on RELRO segments.
54174 + *
54175 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
54176 + * basis because we want to allow the common case and not the special ones.
54177 + */
54178 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
54179 +{
54180 + struct elfhdr elf_h;
54181 + struct elf_phdr elf_p;
54182 + unsigned long i;
54183 + unsigned long oldflags;
54184 + bool is_textrel_rw, is_textrel_rx, is_relro;
54185 +
54186 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
54187 + return;
54188 +
54189 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
54190 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
54191 +
54192 +#ifdef CONFIG_PAX_ELFRELOCS
54193 + /* possible TEXTREL */
54194 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
54195 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
54196 +#else
54197 + is_textrel_rw = false;
54198 + is_textrel_rx = false;
54199 +#endif
54200 +
54201 + /* possible RELRO */
54202 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
54203 +
54204 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
54205 + return;
54206 +
54207 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54208 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54209 +
54210 +#ifdef CONFIG_PAX_ETEXECRELOCS
54211 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54212 +#else
54213 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
54214 +#endif
54215 +
54216 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54217 + !elf_check_arch(&elf_h) ||
54218 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54219 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54220 + return;
54221 +
54222 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54223 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54224 + return;
54225 + switch (elf_p.p_type) {
54226 + case PT_DYNAMIC:
54227 + if (!is_textrel_rw && !is_textrel_rx)
54228 + continue;
54229 + i = 0UL;
54230 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
54231 + elf_dyn dyn;
54232 +
54233 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
54234 + break;
54235 + if (dyn.d_tag == DT_NULL)
54236 + break;
54237 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
54238 + gr_log_textrel(vma);
54239 + if (is_textrel_rw)
54240 + vma->vm_flags |= VM_MAYWRITE;
54241 + else
54242 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
54243 + vma->vm_flags &= ~VM_MAYWRITE;
54244 + break;
54245 + }
54246 + i++;
54247 + }
54248 + is_textrel_rw = false;
54249 + is_textrel_rx = false;
54250 + continue;
54251 +
54252 + case PT_GNU_RELRO:
54253 + if (!is_relro)
54254 + continue;
54255 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
54256 + vma->vm_flags &= ~VM_MAYWRITE;
54257 + is_relro = false;
54258 + continue;
54259 +
54260 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54261 + case PT_PAX_FLAGS: {
54262 + const char *msg_mprotect = "", *msg_emutramp = "";
54263 + char *buffer_lib, *buffer_exe;
54264 +
54265 + if (elf_p.p_flags & PF_NOMPROTECT)
54266 + msg_mprotect = "MPROTECT disabled";
54267 +
54268 +#ifdef CONFIG_PAX_EMUTRAMP
54269 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
54270 + msg_emutramp = "EMUTRAMP enabled";
54271 +#endif
54272 +
54273 + if (!msg_mprotect[0] && !msg_emutramp[0])
54274 + continue;
54275 +
54276 + if (!printk_ratelimit())
54277 + continue;
54278 +
54279 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
54280 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
54281 + if (buffer_lib && buffer_exe) {
54282 + char *path_lib, *path_exe;
54283 +
54284 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
54285 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
54286 +
54287 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
54288 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
54289 +
54290 + }
54291 + free_page((unsigned long)buffer_exe);
54292 + free_page((unsigned long)buffer_lib);
54293 + continue;
54294 + }
54295 +#endif
54296 +
54297 + }
54298 + }
54299 +}
54300 +#endif
54301 +
54302 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
54303 +
54304 +extern int grsec_enable_log_rwxmaps;
54305 +
54306 +static void elf_handle_mmap(struct file *file)
54307 +{
54308 + struct elfhdr elf_h;
54309 + struct elf_phdr elf_p;
54310 + unsigned long i;
54311 +
54312 + if (!grsec_enable_log_rwxmaps)
54313 + return;
54314 +
54315 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54316 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54317 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
54318 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54319 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54320 + return;
54321 +
54322 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54323 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54324 + return;
54325 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
54326 + gr_log_ptgnustack(file);
54327 + }
54328 +}
54329 +#endif
54330 +
54331 static int __init init_elf_binfmt(void)
54332 {
54333 register_binfmt(&elf_format);
54334 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
54335 index d50bbe5..af3b649 100644
54336 --- a/fs/binfmt_flat.c
54337 +++ b/fs/binfmt_flat.c
54338 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
54339 realdatastart = (unsigned long) -ENOMEM;
54340 printk("Unable to allocate RAM for process data, errno %d\n",
54341 (int)-realdatastart);
54342 + down_write(&current->mm->mmap_sem);
54343 vm_munmap(textpos, text_len);
54344 + up_write(&current->mm->mmap_sem);
54345 ret = realdatastart;
54346 goto err;
54347 }
54348 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54349 }
54350 if (IS_ERR_VALUE(result)) {
54351 printk("Unable to read data+bss, errno %d\n", (int)-result);
54352 + down_write(&current->mm->mmap_sem);
54353 vm_munmap(textpos, text_len);
54354 vm_munmap(realdatastart, len);
54355 + up_write(&current->mm->mmap_sem);
54356 ret = result;
54357 goto err;
54358 }
54359 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54360 }
54361 if (IS_ERR_VALUE(result)) {
54362 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
54363 + down_write(&current->mm->mmap_sem);
54364 vm_munmap(textpos, text_len + data_len + extra +
54365 MAX_SHARED_LIBS * sizeof(unsigned long));
54366 + up_write(&current->mm->mmap_sem);
54367 ret = result;
54368 goto err;
54369 }
54370 diff --git a/fs/bio.c b/fs/bio.c
54371 index c5eae72..599e3cf 100644
54372 --- a/fs/bio.c
54373 +++ b/fs/bio.c
54374 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
54375 /*
54376 * Overflow, abort
54377 */
54378 - if (end < start)
54379 + if (end < start || end - start > INT_MAX - nr_pages)
54380 return ERR_PTR(-EINVAL);
54381
54382 nr_pages += end - start;
54383 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
54384 /*
54385 * Overflow, abort
54386 */
54387 - if (end < start)
54388 + if (end < start || end - start > INT_MAX - nr_pages)
54389 return ERR_PTR(-EINVAL);
54390
54391 nr_pages += end - start;
54392 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
54393 const int read = bio_data_dir(bio) == READ;
54394 struct bio_map_data *bmd = bio->bi_private;
54395 int i;
54396 - char *p = bmd->sgvecs[0].iov_base;
54397 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
54398
54399 bio_for_each_segment_all(bvec, bio, i) {
54400 char *addr = page_address(bvec->bv_page);
54401 diff --git a/fs/block_dev.c b/fs/block_dev.c
54402 index 85f5c85..d6f0b1a 100644
54403 --- a/fs/block_dev.c
54404 +++ b/fs/block_dev.c
54405 @@ -658,7 +658,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
54406 else if (bdev->bd_contains == bdev)
54407 return true; /* is a whole device which isn't held */
54408
54409 - else if (whole->bd_holder == bd_may_claim)
54410 + else if (whole->bd_holder == (void *)bd_may_claim)
54411 return true; /* is a partition of a device that is being partitioned */
54412 else if (whole->bd_holder != NULL)
54413 return false; /* is a partition of a held device */
54414 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
54415 index 7fb054b..ad36c67 100644
54416 --- a/fs/btrfs/ctree.c
54417 +++ b/fs/btrfs/ctree.c
54418 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
54419 free_extent_buffer(buf);
54420 add_root_to_dirty_list(root);
54421 } else {
54422 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
54423 - parent_start = parent->start;
54424 - else
54425 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
54426 + if (parent)
54427 + parent_start = parent->start;
54428 + else
54429 + parent_start = 0;
54430 + } else
54431 parent_start = 0;
54432
54433 WARN_ON(trans->transid != btrfs_header_generation(parent));
54434 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
54435 index f26f38c..3d0f149 100644
54436 --- a/fs/btrfs/delayed-inode.c
54437 +++ b/fs/btrfs/delayed-inode.c
54438 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
54439
54440 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
54441 {
54442 - int seq = atomic_inc_return(&delayed_root->items_seq);
54443 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
54444 if ((atomic_dec_return(&delayed_root->items) <
54445 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
54446 waitqueue_active(&delayed_root->wait))
54447 @@ -1391,7 +1391,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
54448 static int refs_newer(struct btrfs_delayed_root *delayed_root,
54449 int seq, int count)
54450 {
54451 - int val = atomic_read(&delayed_root->items_seq);
54452 + int val = atomic_read_unchecked(&delayed_root->items_seq);
54453
54454 if (val < seq || val >= seq + count)
54455 return 1;
54456 @@ -1408,7 +1408,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54457 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54458 return;
54459
54460 - seq = atomic_read(&delayed_root->items_seq);
54461 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54462
54463 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54464 int ret;
54465 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54466 index 1d5c5f7..0ba0afc 100644
54467 --- a/fs/btrfs/delayed-inode.h
54468 +++ b/fs/btrfs/delayed-inode.h
54469 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54470 */
54471 struct list_head prepare_list;
54472 atomic_t items; /* for delayed items */
54473 - atomic_t items_seq; /* for delayed items */
54474 + atomic_unchecked_t items_seq; /* for delayed items */
54475 int nodes; /* for delayed nodes */
54476 wait_queue_head_t wait;
54477 };
54478 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54479 struct btrfs_delayed_root *delayed_root)
54480 {
54481 atomic_set(&delayed_root->items, 0);
54482 - atomic_set(&delayed_root->items_seq, 0);
54483 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54484 delayed_root->nodes = 0;
54485 spin_lock_init(&delayed_root->lock);
54486 init_waitqueue_head(&delayed_root->wait);
54487 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54488 index 0f81d67..0ad55fe 100644
54489 --- a/fs/btrfs/ioctl.c
54490 +++ b/fs/btrfs/ioctl.c
54491 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54492 for (i = 0; i < num_types; i++) {
54493 struct btrfs_space_info *tmp;
54494
54495 + /* Don't copy in more than we allocated */
54496 if (!slot_count)
54497 break;
54498
54499 + slot_count--;
54500 +
54501 info = NULL;
54502 rcu_read_lock();
54503 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54504 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54505 memcpy(dest, &space, sizeof(space));
54506 dest++;
54507 space_args.total_spaces++;
54508 - slot_count--;
54509 }
54510 - if (!slot_count)
54511 - break;
54512 }
54513 up_read(&info->groups_sem);
54514 }
54515 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54516 index f0857e0..e7023c5 100644
54517 --- a/fs/btrfs/super.c
54518 +++ b/fs/btrfs/super.c
54519 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54520 function, line, errstr);
54521 return;
54522 }
54523 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54524 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54525 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
54526 }
54527 /*
54528 diff --git a/fs/buffer.c b/fs/buffer.c
54529 index d2a4d1b..df798ca 100644
54530 --- a/fs/buffer.c
54531 +++ b/fs/buffer.c
54532 @@ -3367,7 +3367,7 @@ void __init buffer_init(void)
54533 bh_cachep = kmem_cache_create("buffer_head",
54534 sizeof(struct buffer_head), 0,
54535 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54536 - SLAB_MEM_SPREAD),
54537 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54538 NULL);
54539
54540 /*
54541 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54542 index 622f469..e8d2d55 100644
54543 --- a/fs/cachefiles/bind.c
54544 +++ b/fs/cachefiles/bind.c
54545 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54546 args);
54547
54548 /* start by checking things over */
54549 - ASSERT(cache->fstop_percent >= 0 &&
54550 - cache->fstop_percent < cache->fcull_percent &&
54551 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54552 cache->fcull_percent < cache->frun_percent &&
54553 cache->frun_percent < 100);
54554
54555 - ASSERT(cache->bstop_percent >= 0 &&
54556 - cache->bstop_percent < cache->bcull_percent &&
54557 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54558 cache->bcull_percent < cache->brun_percent &&
54559 cache->brun_percent < 100);
54560
54561 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54562 index 0a1467b..6a53245 100644
54563 --- a/fs/cachefiles/daemon.c
54564 +++ b/fs/cachefiles/daemon.c
54565 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54566 if (n > buflen)
54567 return -EMSGSIZE;
54568
54569 - if (copy_to_user(_buffer, buffer, n) != 0)
54570 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54571 return -EFAULT;
54572
54573 return n;
54574 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54575 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54576 return -EIO;
54577
54578 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54579 + if (datalen > PAGE_SIZE - 1)
54580 return -EOPNOTSUPP;
54581
54582 /* drag the command string into the kernel so we can parse it */
54583 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54584 if (args[0] != '%' || args[1] != '\0')
54585 return -EINVAL;
54586
54587 - if (fstop < 0 || fstop >= cache->fcull_percent)
54588 + if (fstop >= cache->fcull_percent)
54589 return cachefiles_daemon_range_error(cache, args);
54590
54591 cache->fstop_percent = fstop;
54592 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54593 if (args[0] != '%' || args[1] != '\0')
54594 return -EINVAL;
54595
54596 - if (bstop < 0 || bstop >= cache->bcull_percent)
54597 + if (bstop >= cache->bcull_percent)
54598 return cachefiles_daemon_range_error(cache, args);
54599
54600 cache->bstop_percent = bstop;
54601 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54602 index 4938251..7e01445 100644
54603 --- a/fs/cachefiles/internal.h
54604 +++ b/fs/cachefiles/internal.h
54605 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54606 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54607 struct rb_root active_nodes; /* active nodes (can't be culled) */
54608 rwlock_t active_lock; /* lock for active_nodes */
54609 - atomic_t gravecounter; /* graveyard uniquifier */
54610 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54611 unsigned frun_percent; /* when to stop culling (% files) */
54612 unsigned fcull_percent; /* when to start culling (% files) */
54613 unsigned fstop_percent; /* when to stop allocating (% files) */
54614 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54615 * proc.c
54616 */
54617 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54618 -extern atomic_t cachefiles_lookup_histogram[HZ];
54619 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54620 -extern atomic_t cachefiles_create_histogram[HZ];
54621 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54622 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54623 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54624
54625 extern int __init cachefiles_proc_init(void);
54626 extern void cachefiles_proc_cleanup(void);
54627 static inline
54628 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54629 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54630 {
54631 unsigned long jif = jiffies - start_jif;
54632 if (jif >= HZ)
54633 jif = HZ - 1;
54634 - atomic_inc(&histogram[jif]);
54635 + atomic_inc_unchecked(&histogram[jif]);
54636 }
54637
54638 #else
54639 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54640 index 8c01c5fc..15f982e 100644
54641 --- a/fs/cachefiles/namei.c
54642 +++ b/fs/cachefiles/namei.c
54643 @@ -317,7 +317,7 @@ try_again:
54644 /* first step is to make up a grave dentry in the graveyard */
54645 sprintf(nbuffer, "%08x%08x",
54646 (uint32_t) get_seconds(),
54647 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54648 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54649
54650 /* do the multiway lock magic */
54651 trap = lock_rename(cache->graveyard, dir);
54652 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54653 index eccd339..4c1d995 100644
54654 --- a/fs/cachefiles/proc.c
54655 +++ b/fs/cachefiles/proc.c
54656 @@ -14,9 +14,9 @@
54657 #include <linux/seq_file.h>
54658 #include "internal.h"
54659
54660 -atomic_t cachefiles_lookup_histogram[HZ];
54661 -atomic_t cachefiles_mkdir_histogram[HZ];
54662 -atomic_t cachefiles_create_histogram[HZ];
54663 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54664 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54665 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54666
54667 /*
54668 * display the latency histogram
54669 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54670 return 0;
54671 default:
54672 index = (unsigned long) v - 3;
54673 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54674 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54675 - z = atomic_read(&cachefiles_create_histogram[index]);
54676 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54677 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54678 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54679 if (x == 0 && y == 0 && z == 0)
54680 return 0;
54681
54682 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54683 index 317f9ee..3d24511 100644
54684 --- a/fs/cachefiles/rdwr.c
54685 +++ b/fs/cachefiles/rdwr.c
54686 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54687 old_fs = get_fs();
54688 set_fs(KERNEL_DS);
54689 ret = file->f_op->write(
54690 - file, (const void __user *) data, len, &pos);
54691 + file, (const void __force_user *) data, len, &pos);
54692 set_fs(old_fs);
54693 kunmap(page);
54694 file_end_write(file);
54695 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54696 index f02d82b..2632cf86 100644
54697 --- a/fs/ceph/dir.c
54698 +++ b/fs/ceph/dir.c
54699 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
54700 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54701 struct ceph_mds_client *mdsc = fsc->mdsc;
54702 unsigned frag = fpos_frag(filp->f_pos);
54703 - int off = fpos_off(filp->f_pos);
54704 + unsigned int off = fpos_off(filp->f_pos);
54705 int err;
54706 u32 ftype;
54707 struct ceph_mds_reply_info_parsed *rinfo;
54708 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54709 index 7d377c9..3fb6559 100644
54710 --- a/fs/ceph/super.c
54711 +++ b/fs/ceph/super.c
54712 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54713 /*
54714 * construct our own bdi so we can control readahead, etc.
54715 */
54716 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54717 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54718
54719 static int ceph_register_bdi(struct super_block *sb,
54720 struct ceph_fs_client *fsc)
54721 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
54722 default_backing_dev_info.ra_pages;
54723
54724 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54725 - atomic_long_inc_return(&bdi_seq));
54726 + atomic_long_inc_return_unchecked(&bdi_seq));
54727 if (!err)
54728 sb->s_bdi = &fsc->backing_dev_info;
54729 return err;
54730 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54731 index d597483..747901b 100644
54732 --- a/fs/cifs/cifs_debug.c
54733 +++ b/fs/cifs/cifs_debug.c
54734 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54735
54736 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54737 #ifdef CONFIG_CIFS_STATS2
54738 - atomic_set(&totBufAllocCount, 0);
54739 - atomic_set(&totSmBufAllocCount, 0);
54740 + atomic_set_unchecked(&totBufAllocCount, 0);
54741 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54742 #endif /* CONFIG_CIFS_STATS2 */
54743 spin_lock(&cifs_tcp_ses_lock);
54744 list_for_each(tmp1, &cifs_tcp_ses_list) {
54745 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54746 tcon = list_entry(tmp3,
54747 struct cifs_tcon,
54748 tcon_list);
54749 - atomic_set(&tcon->num_smbs_sent, 0);
54750 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54751 if (server->ops->clear_stats)
54752 server->ops->clear_stats(tcon);
54753 }
54754 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54755 smBufAllocCount.counter, cifs_min_small);
54756 #ifdef CONFIG_CIFS_STATS2
54757 seq_printf(m, "Total Large %d Small %d Allocations\n",
54758 - atomic_read(&totBufAllocCount),
54759 - atomic_read(&totSmBufAllocCount));
54760 + atomic_read_unchecked(&totBufAllocCount),
54761 + atomic_read_unchecked(&totSmBufAllocCount));
54762 #endif /* CONFIG_CIFS_STATS2 */
54763
54764 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54765 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54766 if (tcon->need_reconnect)
54767 seq_puts(m, "\tDISCONNECTED ");
54768 seq_printf(m, "\nSMBs: %d",
54769 - atomic_read(&tcon->num_smbs_sent));
54770 + atomic_read_unchecked(&tcon->num_smbs_sent));
54771 if (server->ops->print_stats)
54772 server->ops->print_stats(m, tcon);
54773 }
54774 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54775 index 3752b9f..8db5569 100644
54776 --- a/fs/cifs/cifsfs.c
54777 +++ b/fs/cifs/cifsfs.c
54778 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
54779 */
54780 cifs_req_cachep = kmem_cache_create("cifs_request",
54781 CIFSMaxBufSize + max_hdr_size, 0,
54782 - SLAB_HWCACHE_ALIGN, NULL);
54783 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54784 if (cifs_req_cachep == NULL)
54785 return -ENOMEM;
54786
54787 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
54788 efficient to alloc 1 per page off the slab compared to 17K (5page)
54789 alloc of large cifs buffers even when page debugging is on */
54790 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54791 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54792 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54793 NULL);
54794 if (cifs_sm_req_cachep == NULL) {
54795 mempool_destroy(cifs_req_poolp);
54796 @@ -1147,8 +1147,8 @@ init_cifs(void)
54797 atomic_set(&bufAllocCount, 0);
54798 atomic_set(&smBufAllocCount, 0);
54799 #ifdef CONFIG_CIFS_STATS2
54800 - atomic_set(&totBufAllocCount, 0);
54801 - atomic_set(&totSmBufAllocCount, 0);
54802 + atomic_set_unchecked(&totBufAllocCount, 0);
54803 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54804 #endif /* CONFIG_CIFS_STATS2 */
54805
54806 atomic_set(&midCount, 0);
54807 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54808 index ea3a0b3..0194e39 100644
54809 --- a/fs/cifs/cifsglob.h
54810 +++ b/fs/cifs/cifsglob.h
54811 @@ -752,35 +752,35 @@ struct cifs_tcon {
54812 __u16 Flags; /* optional support bits */
54813 enum statusEnum tidStatus;
54814 #ifdef CONFIG_CIFS_STATS
54815 - atomic_t num_smbs_sent;
54816 + atomic_unchecked_t num_smbs_sent;
54817 union {
54818 struct {
54819 - atomic_t num_writes;
54820 - atomic_t num_reads;
54821 - atomic_t num_flushes;
54822 - atomic_t num_oplock_brks;
54823 - atomic_t num_opens;
54824 - atomic_t num_closes;
54825 - atomic_t num_deletes;
54826 - atomic_t num_mkdirs;
54827 - atomic_t num_posixopens;
54828 - atomic_t num_posixmkdirs;
54829 - atomic_t num_rmdirs;
54830 - atomic_t num_renames;
54831 - atomic_t num_t2renames;
54832 - atomic_t num_ffirst;
54833 - atomic_t num_fnext;
54834 - atomic_t num_fclose;
54835 - atomic_t num_hardlinks;
54836 - atomic_t num_symlinks;
54837 - atomic_t num_locks;
54838 - atomic_t num_acl_get;
54839 - atomic_t num_acl_set;
54840 + atomic_unchecked_t num_writes;
54841 + atomic_unchecked_t num_reads;
54842 + atomic_unchecked_t num_flushes;
54843 + atomic_unchecked_t num_oplock_brks;
54844 + atomic_unchecked_t num_opens;
54845 + atomic_unchecked_t num_closes;
54846 + atomic_unchecked_t num_deletes;
54847 + atomic_unchecked_t num_mkdirs;
54848 + atomic_unchecked_t num_posixopens;
54849 + atomic_unchecked_t num_posixmkdirs;
54850 + atomic_unchecked_t num_rmdirs;
54851 + atomic_unchecked_t num_renames;
54852 + atomic_unchecked_t num_t2renames;
54853 + atomic_unchecked_t num_ffirst;
54854 + atomic_unchecked_t num_fnext;
54855 + atomic_unchecked_t num_fclose;
54856 + atomic_unchecked_t num_hardlinks;
54857 + atomic_unchecked_t num_symlinks;
54858 + atomic_unchecked_t num_locks;
54859 + atomic_unchecked_t num_acl_get;
54860 + atomic_unchecked_t num_acl_set;
54861 } cifs_stats;
54862 #ifdef CONFIG_CIFS_SMB2
54863 struct {
54864 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54865 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54866 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54867 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54868 } smb2_stats;
54869 #endif /* CONFIG_CIFS_SMB2 */
54870 } stats;
54871 @@ -1081,7 +1081,7 @@ convert_delimiter(char *path, char delim)
54872 }
54873
54874 #ifdef CONFIG_CIFS_STATS
54875 -#define cifs_stats_inc atomic_inc
54876 +#define cifs_stats_inc atomic_inc_unchecked
54877
54878 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54879 unsigned int bytes)
54880 @@ -1446,8 +1446,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54881 /* Various Debug counters */
54882 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54883 #ifdef CONFIG_CIFS_STATS2
54884 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54885 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54886 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54887 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54888 #endif
54889 GLOBAL_EXTERN atomic_t smBufAllocCount;
54890 GLOBAL_EXTERN atomic_t midCount;
54891 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54892 index b83c3f5..6437caa 100644
54893 --- a/fs/cifs/link.c
54894 +++ b/fs/cifs/link.c
54895 @@ -616,7 +616,7 @@ symlink_exit:
54896
54897 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54898 {
54899 - char *p = nd_get_link(nd);
54900 + const char *p = nd_get_link(nd);
54901 if (!IS_ERR(p))
54902 kfree(p);
54903 }
54904 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54905 index 1bec014..f329411 100644
54906 --- a/fs/cifs/misc.c
54907 +++ b/fs/cifs/misc.c
54908 @@ -169,7 +169,7 @@ cifs_buf_get(void)
54909 memset(ret_buf, 0, buf_size + 3);
54910 atomic_inc(&bufAllocCount);
54911 #ifdef CONFIG_CIFS_STATS2
54912 - atomic_inc(&totBufAllocCount);
54913 + atomic_inc_unchecked(&totBufAllocCount);
54914 #endif /* CONFIG_CIFS_STATS2 */
54915 }
54916
54917 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
54918 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54919 atomic_inc(&smBufAllocCount);
54920 #ifdef CONFIG_CIFS_STATS2
54921 - atomic_inc(&totSmBufAllocCount);
54922 + atomic_inc_unchecked(&totSmBufAllocCount);
54923 #endif /* CONFIG_CIFS_STATS2 */
54924
54925 }
54926 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54927 index 3efdb9d..e845a5e 100644
54928 --- a/fs/cifs/smb1ops.c
54929 +++ b/fs/cifs/smb1ops.c
54930 @@ -591,27 +591,27 @@ static void
54931 cifs_clear_stats(struct cifs_tcon *tcon)
54932 {
54933 #ifdef CONFIG_CIFS_STATS
54934 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54935 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54936 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54937 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54938 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54939 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54940 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54941 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54942 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54943 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54944 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54945 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54946 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54947 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54948 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54949 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54950 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54951 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54952 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54953 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54954 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54955 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54956 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54957 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54958 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54959 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54960 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54961 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54962 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54963 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54964 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54965 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54966 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54967 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54968 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54969 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54970 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54971 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54972 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54973 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54974 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54975 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54976 #endif
54977 }
54978
54979 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54980 {
54981 #ifdef CONFIG_CIFS_STATS
54982 seq_printf(m, " Oplocks breaks: %d",
54983 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54984 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54985 seq_printf(m, "\nReads: %d Bytes: %llu",
54986 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54987 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54988 (long long)(tcon->bytes_read));
54989 seq_printf(m, "\nWrites: %d Bytes: %llu",
54990 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54991 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54992 (long long)(tcon->bytes_written));
54993 seq_printf(m, "\nFlushes: %d",
54994 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54995 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54996 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54997 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54998 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54999 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
55000 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
55001 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
55002 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
55003 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
55004 - atomic_read(&tcon->stats.cifs_stats.num_opens),
55005 - atomic_read(&tcon->stats.cifs_stats.num_closes),
55006 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
55007 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
55008 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
55009 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
55010 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
55011 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
55012 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
55013 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
55014 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
55015 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
55016 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
55017 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
55018 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
55019 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
55020 seq_printf(m, "\nRenames: %d T2 Renames %d",
55021 - atomic_read(&tcon->stats.cifs_stats.num_renames),
55022 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
55023 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
55024 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
55025 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
55026 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
55027 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
55028 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
55029 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
55030 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
55031 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
55032 #endif
55033 }
55034
55035 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
55036 index f2e76f3..c44fac7 100644
55037 --- a/fs/cifs/smb2ops.c
55038 +++ b/fs/cifs/smb2ops.c
55039 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
55040 #ifdef CONFIG_CIFS_STATS
55041 int i;
55042 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
55043 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55044 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55045 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55046 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55047 }
55048 #endif
55049 }
55050 @@ -284,66 +284,66 @@ static void
55051 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55052 {
55053 #ifdef CONFIG_CIFS_STATS
55054 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55055 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55056 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55057 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55058 seq_printf(m, "\nNegotiates: %d sent %d failed",
55059 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
55060 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
55061 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
55062 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
55063 seq_printf(m, "\nSessionSetups: %d sent %d failed",
55064 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
55065 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
55066 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
55067 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
55068 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
55069 seq_printf(m, "\nLogoffs: %d sent %d failed",
55070 - atomic_read(&sent[SMB2_LOGOFF_HE]),
55071 - atomic_read(&failed[SMB2_LOGOFF_HE]));
55072 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
55073 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
55074 seq_printf(m, "\nTreeConnects: %d sent %d failed",
55075 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
55076 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
55077 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
55078 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
55079 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
55080 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
55081 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
55082 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
55083 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
55084 seq_printf(m, "\nCreates: %d sent %d failed",
55085 - atomic_read(&sent[SMB2_CREATE_HE]),
55086 - atomic_read(&failed[SMB2_CREATE_HE]));
55087 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
55088 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
55089 seq_printf(m, "\nCloses: %d sent %d failed",
55090 - atomic_read(&sent[SMB2_CLOSE_HE]),
55091 - atomic_read(&failed[SMB2_CLOSE_HE]));
55092 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
55093 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
55094 seq_printf(m, "\nFlushes: %d sent %d failed",
55095 - atomic_read(&sent[SMB2_FLUSH_HE]),
55096 - atomic_read(&failed[SMB2_FLUSH_HE]));
55097 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
55098 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
55099 seq_printf(m, "\nReads: %d sent %d failed",
55100 - atomic_read(&sent[SMB2_READ_HE]),
55101 - atomic_read(&failed[SMB2_READ_HE]));
55102 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
55103 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
55104 seq_printf(m, "\nWrites: %d sent %d failed",
55105 - atomic_read(&sent[SMB2_WRITE_HE]),
55106 - atomic_read(&failed[SMB2_WRITE_HE]));
55107 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
55108 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
55109 seq_printf(m, "\nLocks: %d sent %d failed",
55110 - atomic_read(&sent[SMB2_LOCK_HE]),
55111 - atomic_read(&failed[SMB2_LOCK_HE]));
55112 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
55113 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
55114 seq_printf(m, "\nIOCTLs: %d sent %d failed",
55115 - atomic_read(&sent[SMB2_IOCTL_HE]),
55116 - atomic_read(&failed[SMB2_IOCTL_HE]));
55117 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
55118 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
55119 seq_printf(m, "\nCancels: %d sent %d failed",
55120 - atomic_read(&sent[SMB2_CANCEL_HE]),
55121 - atomic_read(&failed[SMB2_CANCEL_HE]));
55122 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
55123 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
55124 seq_printf(m, "\nEchos: %d sent %d failed",
55125 - atomic_read(&sent[SMB2_ECHO_HE]),
55126 - atomic_read(&failed[SMB2_ECHO_HE]));
55127 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
55128 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
55129 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
55130 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
55131 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
55132 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
55133 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
55134 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
55135 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
55136 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
55137 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
55138 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
55139 seq_printf(m, "\nQueryInfos: %d sent %d failed",
55140 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
55141 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
55142 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
55143 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
55144 seq_printf(m, "\nSetInfos: %d sent %d failed",
55145 - atomic_read(&sent[SMB2_SET_INFO_HE]),
55146 - atomic_read(&failed[SMB2_SET_INFO_HE]));
55147 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
55148 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
55149 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
55150 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
55151 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
55152 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
55153 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
55154 #endif
55155 }
55156
55157 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
55158 index 2b95ce2..d079d75 100644
55159 --- a/fs/cifs/smb2pdu.c
55160 +++ b/fs/cifs/smb2pdu.c
55161 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
55162 default:
55163 cifs_dbg(VFS, "info level %u isn't supported\n",
55164 srch_inf->info_level);
55165 - rc = -EINVAL;
55166 - goto qdir_exit;
55167 + return -EINVAL;
55168 }
55169
55170 req->FileIndex = cpu_to_le32(index);
55171 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
55172 index 1da168c..8bc7ff6 100644
55173 --- a/fs/coda/cache.c
55174 +++ b/fs/coda/cache.c
55175 @@ -24,7 +24,7 @@
55176 #include "coda_linux.h"
55177 #include "coda_cache.h"
55178
55179 -static atomic_t permission_epoch = ATOMIC_INIT(0);
55180 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
55181
55182 /* replace or extend an acl cache hit */
55183 void coda_cache_enter(struct inode *inode, int mask)
55184 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
55185 struct coda_inode_info *cii = ITOC(inode);
55186
55187 spin_lock(&cii->c_lock);
55188 - cii->c_cached_epoch = atomic_read(&permission_epoch);
55189 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
55190 if (!uid_eq(cii->c_uid, current_fsuid())) {
55191 cii->c_uid = current_fsuid();
55192 cii->c_cached_perm = mask;
55193 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
55194 {
55195 struct coda_inode_info *cii = ITOC(inode);
55196 spin_lock(&cii->c_lock);
55197 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
55198 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
55199 spin_unlock(&cii->c_lock);
55200 }
55201
55202 /* remove all acl caches */
55203 void coda_cache_clear_all(struct super_block *sb)
55204 {
55205 - atomic_inc(&permission_epoch);
55206 + atomic_inc_unchecked(&permission_epoch);
55207 }
55208
55209
55210 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
55211 spin_lock(&cii->c_lock);
55212 hit = (mask & cii->c_cached_perm) == mask &&
55213 uid_eq(cii->c_uid, current_fsuid()) &&
55214 - cii->c_cached_epoch == atomic_read(&permission_epoch);
55215 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
55216 spin_unlock(&cii->c_lock);
55217
55218 return hit;
55219 diff --git a/fs/compat.c b/fs/compat.c
55220 index fc3b55d..7b568ae 100644
55221 --- a/fs/compat.c
55222 +++ b/fs/compat.c
55223 @@ -54,7 +54,7 @@
55224 #include <asm/ioctls.h>
55225 #include "internal.h"
55226
55227 -int compat_log = 1;
55228 +int compat_log = 0;
55229
55230 int compat_printk(const char *fmt, ...)
55231 {
55232 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
55233
55234 set_fs(KERNEL_DS);
55235 /* The __user pointer cast is valid because of the set_fs() */
55236 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
55237 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
55238 set_fs(oldfs);
55239 /* truncating is ok because it's a user address */
55240 if (!ret)
55241 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
55242 goto out;
55243
55244 ret = -EINVAL;
55245 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
55246 + if (nr_segs > UIO_MAXIOV)
55247 goto out;
55248 if (nr_segs > fast_segs) {
55249 ret = -ENOMEM;
55250 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
55251
55252 struct compat_readdir_callback {
55253 struct compat_old_linux_dirent __user *dirent;
55254 + struct file * file;
55255 int result;
55256 };
55257
55258 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
55259 buf->result = -EOVERFLOW;
55260 return -EOVERFLOW;
55261 }
55262 +
55263 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55264 + return 0;
55265 +
55266 buf->result++;
55267 dirent = buf->dirent;
55268 if (!access_ok(VERIFY_WRITE, dirent,
55269 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
55270
55271 buf.result = 0;
55272 buf.dirent = dirent;
55273 + buf.file = f.file;
55274
55275 error = vfs_readdir(f.file, compat_fillonedir, &buf);
55276 if (buf.result)
55277 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
55278 struct compat_getdents_callback {
55279 struct compat_linux_dirent __user *current_dir;
55280 struct compat_linux_dirent __user *previous;
55281 + struct file * file;
55282 int count;
55283 int error;
55284 };
55285 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
55286 buf->error = -EOVERFLOW;
55287 return -EOVERFLOW;
55288 }
55289 +
55290 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55291 + return 0;
55292 +
55293 dirent = buf->previous;
55294 if (dirent) {
55295 if (__put_user(offset, &dirent->d_off))
55296 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55297 buf.previous = NULL;
55298 buf.count = count;
55299 buf.error = 0;
55300 + buf.file = f.file;
55301
55302 error = vfs_readdir(f.file, compat_filldir, &buf);
55303 if (error >= 0)
55304 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55305 struct compat_getdents_callback64 {
55306 struct linux_dirent64 __user *current_dir;
55307 struct linux_dirent64 __user *previous;
55308 + struct file * file;
55309 int count;
55310 int error;
55311 };
55312 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
55313 buf->error = -EINVAL; /* only used if we fail.. */
55314 if (reclen > buf->count)
55315 return -EINVAL;
55316 +
55317 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55318 + return 0;
55319 +
55320 dirent = buf->previous;
55321
55322 if (dirent) {
55323 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
55324 buf.previous = NULL;
55325 buf.count = count;
55326 buf.error = 0;
55327 + buf.file = f.file;
55328
55329 error = vfs_readdir(f.file, compat_filldir64, &buf);
55330 if (error >= 0)
55331 error = buf.error;
55332 lastdirent = buf.previous;
55333 if (lastdirent) {
55334 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55335 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55336 if (__put_user_unaligned(d_off, &lastdirent->d_off))
55337 error = -EFAULT;
55338 else
55339 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
55340 index a81147e..20bf2b5 100644
55341 --- a/fs/compat_binfmt_elf.c
55342 +++ b/fs/compat_binfmt_elf.c
55343 @@ -30,11 +30,13 @@
55344 #undef elf_phdr
55345 #undef elf_shdr
55346 #undef elf_note
55347 +#undef elf_dyn
55348 #undef elf_addr_t
55349 #define elfhdr elf32_hdr
55350 #define elf_phdr elf32_phdr
55351 #define elf_shdr elf32_shdr
55352 #define elf_note elf32_note
55353 +#define elf_dyn Elf32_Dyn
55354 #define elf_addr_t Elf32_Addr
55355
55356 /*
55357 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
55358 index 996cdc5..15e2f33 100644
55359 --- a/fs/compat_ioctl.c
55360 +++ b/fs/compat_ioctl.c
55361 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
55362 return -EFAULT;
55363 if (__get_user(udata, &ss32->iomem_base))
55364 return -EFAULT;
55365 - ss.iomem_base = compat_ptr(udata);
55366 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
55367 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
55368 __get_user(ss.port_high, &ss32->port_high))
55369 return -EFAULT;
55370 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
55371 for (i = 0; i < nmsgs; i++) {
55372 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
55373 return -EFAULT;
55374 - if (get_user(datap, &umsgs[i].buf) ||
55375 - put_user(compat_ptr(datap), &tmsgs[i].buf))
55376 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
55377 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
55378 return -EFAULT;
55379 }
55380 return sys_ioctl(fd, cmd, (unsigned long)tdata);
55381 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
55382 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
55383 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
55384 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
55385 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55386 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55387 return -EFAULT;
55388
55389 return ioctl_preallocate(file, p);
55390 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
55391 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
55392 {
55393 unsigned int a, b;
55394 - a = *(unsigned int *)p;
55395 - b = *(unsigned int *)q;
55396 + a = *(const unsigned int *)p;
55397 + b = *(const unsigned int *)q;
55398 if (a > b)
55399 return 1;
55400 if (a < b)
55401 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
55402 index 7aabc6a..34c1197 100644
55403 --- a/fs/configfs/dir.c
55404 +++ b/fs/configfs/dir.c
55405 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
55406 }
55407 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
55408 struct configfs_dirent *next;
55409 - const char * name;
55410 + const unsigned char * name;
55411 + char d_name[sizeof(next->s_dentry->d_iname)];
55412 int len;
55413 struct inode *inode = NULL;
55414
55415 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
55416 continue;
55417
55418 name = configfs_get_name(next);
55419 - len = strlen(name);
55420 + if (next->s_dentry && name == next->s_dentry->d_iname) {
55421 + len = next->s_dentry->d_name.len;
55422 + memcpy(d_name, name, len);
55423 + name = d_name;
55424 + } else
55425 + len = strlen(name);
55426
55427 /*
55428 * We'll have a dentry and an inode for
55429 diff --git a/fs/coredump.c b/fs/coredump.c
55430 index dafafba..10b3b27 100644
55431 --- a/fs/coredump.c
55432 +++ b/fs/coredump.c
55433 @@ -52,7 +52,7 @@ struct core_name {
55434 char *corename;
55435 int used, size;
55436 };
55437 -static atomic_t call_count = ATOMIC_INIT(1);
55438 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
55439
55440 /* The maximal length of core_pattern is also specified in sysctl.c */
55441
55442 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
55443 {
55444 char *old_corename = cn->corename;
55445
55446 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
55447 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
55448 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
55449
55450 if (!cn->corename) {
55451 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
55452 int pid_in_pattern = 0;
55453 int err = 0;
55454
55455 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
55456 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
55457 cn->corename = kmalloc(cn->size, GFP_KERNEL);
55458 cn->used = 0;
55459
55460 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
55461 struct pipe_inode_info *pipe = file->private_data;
55462
55463 pipe_lock(pipe);
55464 - pipe->readers++;
55465 - pipe->writers--;
55466 + atomic_inc(&pipe->readers);
55467 + atomic_dec(&pipe->writers);
55468 wake_up_interruptible_sync(&pipe->wait);
55469 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55470 pipe_unlock(pipe);
55471 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
55472 * We actually want wait_event_freezable() but then we need
55473 * to clear TIF_SIGPENDING and improve dump_interrupted().
55474 */
55475 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
55476 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
55477
55478 pipe_lock(pipe);
55479 - pipe->readers--;
55480 - pipe->writers++;
55481 + atomic_dec(&pipe->readers);
55482 + atomic_inc(&pipe->writers);
55483 pipe_unlock(pipe);
55484 }
55485
55486 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
55487 struct files_struct *displaced;
55488 bool need_nonrelative = false;
55489 bool core_dumped = false;
55490 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55491 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55492 + long signr = siginfo->si_signo;
55493 struct coredump_params cprm = {
55494 .siginfo = siginfo,
55495 .regs = signal_pt_regs(),
55496 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
55497 .mm_flags = mm->flags,
55498 };
55499
55500 - audit_core_dumps(siginfo->si_signo);
55501 + audit_core_dumps(signr);
55502 +
55503 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55504 + gr_handle_brute_attach(cprm.mm_flags);
55505
55506 binfmt = mm->binfmt;
55507 if (!binfmt || !binfmt->core_dump)
55508 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
55509 need_nonrelative = true;
55510 }
55511
55512 - retval = coredump_wait(siginfo->si_signo, &core_state);
55513 + retval = coredump_wait(signr, &core_state);
55514 if (retval < 0)
55515 goto fail_creds;
55516
55517 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
55518 }
55519 cprm.limit = RLIM_INFINITY;
55520
55521 - dump_count = atomic_inc_return(&core_dump_count);
55522 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55523 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55524 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55525 task_tgid_vnr(current), current->comm);
55526 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
55527 } else {
55528 struct inode *inode;
55529
55530 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55531 +
55532 if (cprm.limit < binfmt->min_coredump)
55533 goto fail_unlock;
55534
55535 @@ -666,7 +672,7 @@ close_fail:
55536 filp_close(cprm.file, NULL);
55537 fail_dropcount:
55538 if (ispipe)
55539 - atomic_dec(&core_dump_count);
55540 + atomic_dec_unchecked(&core_dump_count);
55541 fail_unlock:
55542 kfree(cn.corename);
55543 fail_corename:
55544 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55545 {
55546 return !dump_interrupted() &&
55547 access_ok(VERIFY_READ, addr, nr) &&
55548 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55549 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55550 }
55551 EXPORT_SYMBOL(dump_write);
55552
55553 diff --git a/fs/dcache.c b/fs/dcache.c
55554 index f09b908..04b9690 100644
55555 --- a/fs/dcache.c
55556 +++ b/fs/dcache.c
55557 @@ -3086,7 +3086,8 @@ void __init vfs_caches_init(unsigned long mempages)
55558 mempages -= reserve;
55559
55560 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55561 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55562 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55563 + SLAB_NO_SANITIZE, NULL);
55564
55565 dcache_init();
55566 inode_init();
55567 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55568 index c7c83ff..bda9461 100644
55569 --- a/fs/debugfs/inode.c
55570 +++ b/fs/debugfs/inode.c
55571 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55572 */
55573 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55574 {
55575 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55576 + return __create_file(name, S_IFDIR | S_IRWXU,
55577 +#else
55578 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55579 +#endif
55580 parent, NULL, NULL);
55581 }
55582 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55583 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55584 index 5eab400..810a3f5 100644
55585 --- a/fs/ecryptfs/inode.c
55586 +++ b/fs/ecryptfs/inode.c
55587 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55588 old_fs = get_fs();
55589 set_fs(get_ds());
55590 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55591 - (char __user *)lower_buf,
55592 + (char __force_user *)lower_buf,
55593 PATH_MAX);
55594 set_fs(old_fs);
55595 if (rc < 0)
55596 @@ -706,7 +706,7 @@ out:
55597 static void
55598 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55599 {
55600 - char *buf = nd_get_link(nd);
55601 + const char *buf = nd_get_link(nd);
55602 if (!IS_ERR(buf)) {
55603 /* Free the char* */
55604 kfree(buf);
55605 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55606 index e4141f2..d8263e8 100644
55607 --- a/fs/ecryptfs/miscdev.c
55608 +++ b/fs/ecryptfs/miscdev.c
55609 @@ -304,7 +304,7 @@ check_list:
55610 goto out_unlock_msg_ctx;
55611 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55612 if (msg_ctx->msg) {
55613 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55614 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55615 goto out_unlock_msg_ctx;
55616 i += packet_length_size;
55617 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55618 diff --git a/fs/exec.c b/fs/exec.c
55619 index 1f44670..3c84660 100644
55620 --- a/fs/exec.c
55621 +++ b/fs/exec.c
55622 @@ -55,8 +55,20 @@
55623 #include <linux/pipe_fs_i.h>
55624 #include <linux/oom.h>
55625 #include <linux/compat.h>
55626 +#include <linux/random.h>
55627 +#include <linux/seq_file.h>
55628 +#include <linux/coredump.h>
55629 +#include <linux/mman.h>
55630 +
55631 +#ifdef CONFIG_PAX_REFCOUNT
55632 +#include <linux/kallsyms.h>
55633 +#include <linux/kdebug.h>
55634 +#endif
55635 +
55636 +#include <trace/events/fs.h>
55637
55638 #include <asm/uaccess.h>
55639 +#include <asm/sections.h>
55640 #include <asm/mmu_context.h>
55641 #include <asm/tlb.h>
55642
55643 @@ -66,17 +78,32 @@
55644
55645 #include <trace/events/sched.h>
55646
55647 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55648 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55649 +{
55650 + 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");
55651 +}
55652 +#endif
55653 +
55654 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55655 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55656 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55657 +#endif
55658 +
55659 int suid_dumpable = 0;
55660
55661 static LIST_HEAD(formats);
55662 static DEFINE_RWLOCK(binfmt_lock);
55663
55664 +extern int gr_process_kernel_exec_ban(void);
55665 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55666 +
55667 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55668 {
55669 BUG_ON(!fmt);
55670 write_lock(&binfmt_lock);
55671 - insert ? list_add(&fmt->lh, &formats) :
55672 - list_add_tail(&fmt->lh, &formats);
55673 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55674 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55675 write_unlock(&binfmt_lock);
55676 }
55677
55678 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
55679 void unregister_binfmt(struct linux_binfmt * fmt)
55680 {
55681 write_lock(&binfmt_lock);
55682 - list_del(&fmt->lh);
55683 + pax_list_del((struct list_head *)&fmt->lh);
55684 write_unlock(&binfmt_lock);
55685 }
55686
55687 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55688 int write)
55689 {
55690 struct page *page;
55691 - int ret;
55692
55693 -#ifdef CONFIG_STACK_GROWSUP
55694 - if (write) {
55695 - ret = expand_downwards(bprm->vma, pos);
55696 - if (ret < 0)
55697 - return NULL;
55698 - }
55699 -#endif
55700 - ret = get_user_pages(current, bprm->mm, pos,
55701 - 1, write, 1, &page, NULL);
55702 - if (ret <= 0)
55703 + if (0 > expand_downwards(bprm->vma, pos))
55704 + return NULL;
55705 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55706 return NULL;
55707
55708 if (write) {
55709 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55710 if (size <= ARG_MAX)
55711 return page;
55712
55713 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55714 + // only allow 512KB for argv+env on suid/sgid binaries
55715 + // to prevent easy ASLR exhaustion
55716 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55717 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55718 + (size > (512 * 1024))) {
55719 + put_page(page);
55720 + return NULL;
55721 + }
55722 +#endif
55723 +
55724 /*
55725 * Limit to 1/4-th the stack size for the argv+env strings.
55726 * This ensures that:
55727 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55728 vma->vm_end = STACK_TOP_MAX;
55729 vma->vm_start = vma->vm_end - PAGE_SIZE;
55730 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55731 +
55732 +#ifdef CONFIG_PAX_SEGMEXEC
55733 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55734 +#endif
55735 +
55736 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55737 INIT_LIST_HEAD(&vma->anon_vma_chain);
55738
55739 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55740 mm->stack_vm = mm->total_vm = 1;
55741 up_write(&mm->mmap_sem);
55742 bprm->p = vma->vm_end - sizeof(void *);
55743 +
55744 +#ifdef CONFIG_PAX_RANDUSTACK
55745 + if (randomize_va_space)
55746 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55747 +#endif
55748 +
55749 return 0;
55750 err:
55751 up_write(&mm->mmap_sem);
55752 @@ -396,7 +437,7 @@ struct user_arg_ptr {
55753 } ptr;
55754 };
55755
55756 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55757 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55758 {
55759 const char __user *native;
55760
55761 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55762 compat_uptr_t compat;
55763
55764 if (get_user(compat, argv.ptr.compat + nr))
55765 - return ERR_PTR(-EFAULT);
55766 + return (const char __force_user *)ERR_PTR(-EFAULT);
55767
55768 return compat_ptr(compat);
55769 }
55770 #endif
55771
55772 if (get_user(native, argv.ptr.native + nr))
55773 - return ERR_PTR(-EFAULT);
55774 + return (const char __force_user *)ERR_PTR(-EFAULT);
55775
55776 return native;
55777 }
55778 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
55779 if (!p)
55780 break;
55781
55782 - if (IS_ERR(p))
55783 + if (IS_ERR((const char __force_kernel *)p))
55784 return -EFAULT;
55785
55786 if (i >= max)
55787 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55788
55789 ret = -EFAULT;
55790 str = get_user_arg_ptr(argv, argc);
55791 - if (IS_ERR(str))
55792 + if (IS_ERR((const char __force_kernel *)str))
55793 goto out;
55794
55795 len = strnlen_user(str, MAX_ARG_STRLEN);
55796 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55797 int r;
55798 mm_segment_t oldfs = get_fs();
55799 struct user_arg_ptr argv = {
55800 - .ptr.native = (const char __user *const __user *)__argv,
55801 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55802 };
55803
55804 set_fs(KERNEL_DS);
55805 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55806 unsigned long new_end = old_end - shift;
55807 struct mmu_gather tlb;
55808
55809 - BUG_ON(new_start > new_end);
55810 + if (new_start >= new_end || new_start < mmap_min_addr)
55811 + return -ENOMEM;
55812
55813 /*
55814 * ensure there are no vmas between where we want to go
55815 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55816 if (vma != find_vma(mm, new_start))
55817 return -EFAULT;
55818
55819 +#ifdef CONFIG_PAX_SEGMEXEC
55820 + BUG_ON(pax_find_mirror_vma(vma));
55821 +#endif
55822 +
55823 /*
55824 * cover the whole range: [new_start, old_end)
55825 */
55826 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55827 stack_top = arch_align_stack(stack_top);
55828 stack_top = PAGE_ALIGN(stack_top);
55829
55830 - if (unlikely(stack_top < mmap_min_addr) ||
55831 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55832 - return -ENOMEM;
55833 -
55834 stack_shift = vma->vm_end - stack_top;
55835
55836 bprm->p -= stack_shift;
55837 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55838 bprm->exec -= stack_shift;
55839
55840 down_write(&mm->mmap_sem);
55841 +
55842 + /* Move stack pages down in memory. */
55843 + if (stack_shift) {
55844 + ret = shift_arg_pages(vma, stack_shift);
55845 + if (ret)
55846 + goto out_unlock;
55847 + }
55848 +
55849 vm_flags = VM_STACK_FLAGS;
55850
55851 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55852 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55853 + vm_flags &= ~VM_EXEC;
55854 +
55855 +#ifdef CONFIG_PAX_MPROTECT
55856 + if (mm->pax_flags & MF_PAX_MPROTECT)
55857 + vm_flags &= ~VM_MAYEXEC;
55858 +#endif
55859 +
55860 + }
55861 +#endif
55862 +
55863 /*
55864 * Adjust stack execute permissions; explicitly enable for
55865 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55866 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55867 goto out_unlock;
55868 BUG_ON(prev != vma);
55869
55870 - /* Move stack pages down in memory. */
55871 - if (stack_shift) {
55872 - ret = shift_arg_pages(vma, stack_shift);
55873 - if (ret)
55874 - goto out_unlock;
55875 - }
55876 -
55877 /* mprotect_fixup is overkill to remove the temporary stack flags */
55878 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55879
55880 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55881 #endif
55882 current->mm->start_stack = bprm->p;
55883 ret = expand_stack(vma, stack_base);
55884 +
55885 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55886 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55887 + unsigned long size;
55888 + vm_flags_t vm_flags;
55889 +
55890 + size = STACK_TOP - vma->vm_end;
55891 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55892 +
55893 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55894 +
55895 +#ifdef CONFIG_X86
55896 + if (!ret) {
55897 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55898 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55899 + }
55900 +#endif
55901 +
55902 + }
55903 +#endif
55904 +
55905 if (ret)
55906 ret = -EFAULT;
55907
55908 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
55909
55910 fsnotify_open(file);
55911
55912 + trace_open_exec(name);
55913 +
55914 err = deny_write_access(file);
55915 if (err)
55916 goto exit;
55917 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
55918 old_fs = get_fs();
55919 set_fs(get_ds());
55920 /* The cast to a user pointer is valid due to the set_fs() */
55921 - result = vfs_read(file, (void __user *)addr, count, &pos);
55922 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55923 set_fs(old_fs);
55924 return result;
55925 }
55926 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55927 }
55928 rcu_read_unlock();
55929
55930 - if (p->fs->users > n_fs) {
55931 + if (atomic_read(&p->fs->users) > n_fs) {
55932 bprm->unsafe |= LSM_UNSAFE_SHARE;
55933 } else {
55934 res = -EAGAIN;
55935 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
55936
55937 EXPORT_SYMBOL(search_binary_handler);
55938
55939 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55940 +static DEFINE_PER_CPU(u64, exec_counter);
55941 +static int __init init_exec_counters(void)
55942 +{
55943 + unsigned int cpu;
55944 +
55945 + for_each_possible_cpu(cpu) {
55946 + per_cpu(exec_counter, cpu) = (u64)cpu;
55947 + }
55948 +
55949 + return 0;
55950 +}
55951 +early_initcall(init_exec_counters);
55952 +static inline void increment_exec_counter(void)
55953 +{
55954 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55955 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55956 +}
55957 +#else
55958 +static inline void increment_exec_counter(void) {}
55959 +#endif
55960 +
55961 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55962 + struct user_arg_ptr argv);
55963 +
55964 /*
55965 * sys_execve() executes a new program.
55966 */
55967 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
55968 struct user_arg_ptr argv,
55969 struct user_arg_ptr envp)
55970 {
55971 +#ifdef CONFIG_GRKERNSEC
55972 + struct file *old_exec_file;
55973 + struct acl_subject_label *old_acl;
55974 + struct rlimit old_rlim[RLIM_NLIMITS];
55975 +#endif
55976 struct linux_binprm *bprm;
55977 struct file *file;
55978 struct files_struct *displaced;
55979 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
55980 int retval;
55981 const struct cred *cred = current_cred();
55982
55983 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
55984 +
55985 /*
55986 * We move the actual failure in case of RLIMIT_NPROC excess from
55987 * set*uid() to execve() because too many poorly written programs
55988 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
55989 if (IS_ERR(file))
55990 goto out_unmark;
55991
55992 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55993 + retval = -EPERM;
55994 + goto out_file;
55995 + }
55996 +
55997 sched_exec();
55998
55999 bprm->file = file;
56000 bprm->filename = filename;
56001 bprm->interp = filename;
56002
56003 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
56004 + retval = -EACCES;
56005 + goto out_file;
56006 + }
56007 +
56008 retval = bprm_mm_init(bprm);
56009 if (retval)
56010 goto out_file;
56011 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
56012 if (retval < 0)
56013 goto out;
56014
56015 +#ifdef CONFIG_GRKERNSEC
56016 + old_acl = current->acl;
56017 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
56018 + old_exec_file = current->exec_file;
56019 + get_file(file);
56020 + current->exec_file = file;
56021 +#endif
56022 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56023 + /* limit suid stack to 8MB
56024 + * we saved the old limits above and will restore them if this exec fails
56025 + */
56026 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
56027 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
56028 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
56029 +#endif
56030 +
56031 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
56032 + retval = -EPERM;
56033 + goto out_fail;
56034 + }
56035 +
56036 + if (!gr_tpe_allow(file)) {
56037 + retval = -EACCES;
56038 + goto out_fail;
56039 + }
56040 +
56041 + if (gr_check_crash_exec(file)) {
56042 + retval = -EACCES;
56043 + goto out_fail;
56044 + }
56045 +
56046 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
56047 + bprm->unsafe);
56048 + if (retval < 0)
56049 + goto out_fail;
56050 +
56051 retval = copy_strings_kernel(1, &bprm->filename, bprm);
56052 if (retval < 0)
56053 - goto out;
56054 + goto out_fail;
56055
56056 bprm->exec = bprm->p;
56057 retval = copy_strings(bprm->envc, envp, bprm);
56058 if (retval < 0)
56059 - goto out;
56060 + goto out_fail;
56061
56062 retval = copy_strings(bprm->argc, argv, bprm);
56063 if (retval < 0)
56064 - goto out;
56065 + goto out_fail;
56066 +
56067 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
56068 +
56069 + gr_handle_exec_args(bprm, argv);
56070
56071 retval = search_binary_handler(bprm);
56072 if (retval < 0)
56073 - goto out;
56074 + goto out_fail;
56075 +#ifdef CONFIG_GRKERNSEC
56076 + if (old_exec_file)
56077 + fput(old_exec_file);
56078 +#endif
56079
56080 /* execve succeeded */
56081 +
56082 + increment_exec_counter();
56083 current->fs->in_exec = 0;
56084 current->in_execve = 0;
56085 acct_update_integrals(current);
56086 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
56087 put_files_struct(displaced);
56088 return retval;
56089
56090 +out_fail:
56091 +#ifdef CONFIG_GRKERNSEC
56092 + current->acl = old_acl;
56093 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
56094 + fput(current->exec_file);
56095 + current->exec_file = old_exec_file;
56096 +#endif
56097 +
56098 out:
56099 if (bprm->mm) {
56100 acct_arg_size(bprm, 0);
56101 @@ -1701,3 +1875,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
56102 return error;
56103 }
56104 #endif
56105 +
56106 +int pax_check_flags(unsigned long *flags)
56107 +{
56108 + int retval = 0;
56109 +
56110 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
56111 + if (*flags & MF_PAX_SEGMEXEC)
56112 + {
56113 + *flags &= ~MF_PAX_SEGMEXEC;
56114 + retval = -EINVAL;
56115 + }
56116 +#endif
56117 +
56118 + if ((*flags & MF_PAX_PAGEEXEC)
56119 +
56120 +#ifdef CONFIG_PAX_PAGEEXEC
56121 + && (*flags & MF_PAX_SEGMEXEC)
56122 +#endif
56123 +
56124 + )
56125 + {
56126 + *flags &= ~MF_PAX_PAGEEXEC;
56127 + retval = -EINVAL;
56128 + }
56129 +
56130 + if ((*flags & MF_PAX_MPROTECT)
56131 +
56132 +#ifdef CONFIG_PAX_MPROTECT
56133 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56134 +#endif
56135 +
56136 + )
56137 + {
56138 + *flags &= ~MF_PAX_MPROTECT;
56139 + retval = -EINVAL;
56140 + }
56141 +
56142 + if ((*flags & MF_PAX_EMUTRAMP)
56143 +
56144 +#ifdef CONFIG_PAX_EMUTRAMP
56145 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56146 +#endif
56147 +
56148 + )
56149 + {
56150 + *flags &= ~MF_PAX_EMUTRAMP;
56151 + retval = -EINVAL;
56152 + }
56153 +
56154 + return retval;
56155 +}
56156 +
56157 +EXPORT_SYMBOL(pax_check_flags);
56158 +
56159 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56160 +char *pax_get_path(const struct path *path, char *buf, int buflen)
56161 +{
56162 + char *pathname = d_path(path, buf, buflen);
56163 +
56164 + if (IS_ERR(pathname))
56165 + goto toolong;
56166 +
56167 + pathname = mangle_path(buf, pathname, "\t\n\\");
56168 + if (!pathname)
56169 + goto toolong;
56170 +
56171 + *pathname = 0;
56172 + return buf;
56173 +
56174 +toolong:
56175 + return "<path too long>";
56176 +}
56177 +EXPORT_SYMBOL(pax_get_path);
56178 +
56179 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
56180 +{
56181 + struct task_struct *tsk = current;
56182 + struct mm_struct *mm = current->mm;
56183 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
56184 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
56185 + char *path_exec = NULL;
56186 + char *path_fault = NULL;
56187 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
56188 + siginfo_t info = { };
56189 +
56190 + if (buffer_exec && buffer_fault) {
56191 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
56192 +
56193 + down_read(&mm->mmap_sem);
56194 + vma = mm->mmap;
56195 + while (vma && (!vma_exec || !vma_fault)) {
56196 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
56197 + vma_exec = vma;
56198 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
56199 + vma_fault = vma;
56200 + vma = vma->vm_next;
56201 + }
56202 + if (vma_exec)
56203 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
56204 + if (vma_fault) {
56205 + start = vma_fault->vm_start;
56206 + end = vma_fault->vm_end;
56207 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
56208 + if (vma_fault->vm_file)
56209 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
56210 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
56211 + path_fault = "<heap>";
56212 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
56213 + path_fault = "<stack>";
56214 + else
56215 + path_fault = "<anonymous mapping>";
56216 + }
56217 + up_read(&mm->mmap_sem);
56218 + }
56219 + if (tsk->signal->curr_ip)
56220 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
56221 + else
56222 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
56223 + 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),
56224 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
56225 + free_page((unsigned long)buffer_exec);
56226 + free_page((unsigned long)buffer_fault);
56227 + pax_report_insns(regs, pc, sp);
56228 + info.si_signo = SIGKILL;
56229 + info.si_errno = 0;
56230 + info.si_code = SI_KERNEL;
56231 + info.si_pid = 0;
56232 + info.si_uid = 0;
56233 + do_coredump(&info);
56234 +}
56235 +#endif
56236 +
56237 +#ifdef CONFIG_PAX_REFCOUNT
56238 +void pax_report_refcount_overflow(struct pt_regs *regs)
56239 +{
56240 + if (current->signal->curr_ip)
56241 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
56242 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
56243 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56244 + else
56245 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
56246 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56247 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
56248 + preempt_disable();
56249 + show_regs(regs);
56250 + preempt_enable();
56251 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
56252 +}
56253 +#endif
56254 +
56255 +#ifdef CONFIG_PAX_USERCOPY
56256 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
56257 +static noinline int check_stack_object(const void *obj, unsigned long len)
56258 +{
56259 + const void * const stack = task_stack_page(current);
56260 + const void * const stackend = stack + THREAD_SIZE;
56261 +
56262 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56263 + const void *frame = NULL;
56264 + const void *oldframe;
56265 +#endif
56266 +
56267 + if (obj + len < obj)
56268 + return -1;
56269 +
56270 + if (obj + len <= stack || stackend <= obj)
56271 + return 0;
56272 +
56273 + if (obj < stack || stackend < obj + len)
56274 + return -1;
56275 +
56276 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56277 + oldframe = __builtin_frame_address(1);
56278 + if (oldframe)
56279 + frame = __builtin_frame_address(2);
56280 + /*
56281 + low ----------------------------------------------> high
56282 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
56283 + ^----------------^
56284 + allow copies only within here
56285 + */
56286 + while (stack <= frame && frame < stackend) {
56287 + /* if obj + len extends past the last frame, this
56288 + check won't pass and the next frame will be 0,
56289 + causing us to bail out and correctly report
56290 + the copy as invalid
56291 + */
56292 + if (obj + len <= frame)
56293 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
56294 + oldframe = frame;
56295 + frame = *(const void * const *)frame;
56296 + }
56297 + return -1;
56298 +#else
56299 + return 1;
56300 +#endif
56301 +}
56302 +
56303 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
56304 +{
56305 + if (current->signal->curr_ip)
56306 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56307 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56308 + else
56309 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56310 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56311 + dump_stack();
56312 + gr_handle_kernel_exploit();
56313 + do_group_exit(SIGKILL);
56314 +}
56315 +#endif
56316 +
56317 +#ifdef CONFIG_PAX_USERCOPY
56318 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
56319 +{
56320 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
56321 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
56322 +#ifdef CONFIG_MODULES
56323 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
56324 +#else
56325 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
56326 +#endif
56327 +
56328 +#else
56329 + unsigned long textlow = (unsigned long)_stext;
56330 + unsigned long texthigh = (unsigned long)_etext;
56331 +#endif
56332 +
56333 + if (high <= textlow || low > texthigh)
56334 + return false;
56335 + else
56336 + return true;
56337 +}
56338 +#endif
56339 +
56340 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
56341 +{
56342 +
56343 +#ifdef CONFIG_PAX_USERCOPY
56344 + const char *type;
56345 +
56346 + if (!n)
56347 + return;
56348 +
56349 + type = check_heap_object(ptr, n);
56350 + if (!type) {
56351 + int ret = check_stack_object(ptr, n);
56352 + if (ret == 1 || ret == 2)
56353 + return;
56354 + if (ret == 0) {
56355 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
56356 + type = "<kernel text>";
56357 + else
56358 + return;
56359 + } else
56360 + type = "<process stack>";
56361 + }
56362 +
56363 + pax_report_usercopy(ptr, n, to_user, type);
56364 +#endif
56365 +
56366 +}
56367 +EXPORT_SYMBOL(__check_object_size);
56368 +
56369 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
56370 +void pax_track_stack(void)
56371 +{
56372 + unsigned long sp = (unsigned long)&sp;
56373 + if (sp < current_thread_info()->lowest_stack &&
56374 + sp > (unsigned long)task_stack_page(current))
56375 + current_thread_info()->lowest_stack = sp;
56376 +}
56377 +EXPORT_SYMBOL(pax_track_stack);
56378 +#endif
56379 +
56380 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
56381 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
56382 +{
56383 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
56384 + dump_stack();
56385 + do_group_exit(SIGKILL);
56386 +}
56387 +EXPORT_SYMBOL(report_size_overflow);
56388 +#endif
56389 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
56390 index 9f9992b..8b59411 100644
56391 --- a/fs/ext2/balloc.c
56392 +++ b/fs/ext2/balloc.c
56393 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
56394
56395 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56396 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56397 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56398 + if (free_blocks < root_blocks + 1 &&
56399 !uid_eq(sbi->s_resuid, current_fsuid()) &&
56400 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56401 - !in_group_p (sbi->s_resgid))) {
56402 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56403 return 0;
56404 }
56405 return 1;
56406 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
56407 index 22548f5..41521d8 100644
56408 --- a/fs/ext3/balloc.c
56409 +++ b/fs/ext3/balloc.c
56410 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
56411
56412 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56413 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56414 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56415 + if (free_blocks < root_blocks + 1 &&
56416 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
56417 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56418 - !in_group_p (sbi->s_resgid))) {
56419 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56420 return 0;
56421 }
56422 return 1;
56423 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56424 index 3742e4c..69a797f 100644
56425 --- a/fs/ext4/balloc.c
56426 +++ b/fs/ext4/balloc.c
56427 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56428 /* Hm, nope. Are (enough) root reserved clusters available? */
56429 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56430 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56431 - capable(CAP_SYS_RESOURCE) ||
56432 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56433 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56434 + capable_nolog(CAP_SYS_RESOURCE)) {
56435
56436 if (free_clusters >= (nclusters + dirty_clusters +
56437 resv_clusters))
56438 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56439 index 5aae3d1..b5da7f8 100644
56440 --- a/fs/ext4/ext4.h
56441 +++ b/fs/ext4/ext4.h
56442 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
56443 unsigned long s_mb_last_start;
56444
56445 /* stats for buddy allocator */
56446 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56447 - atomic_t s_bal_success; /* we found long enough chunks */
56448 - atomic_t s_bal_allocated; /* in blocks */
56449 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56450 - atomic_t s_bal_goals; /* goal hits */
56451 - atomic_t s_bal_breaks; /* too long searches */
56452 - atomic_t s_bal_2orders; /* 2^order hits */
56453 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56454 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56455 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56456 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56457 + atomic_unchecked_t s_bal_goals; /* goal hits */
56458 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56459 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56460 spinlock_t s_bal_lock;
56461 unsigned long s_mb_buddies_generated;
56462 unsigned long long s_mb_generation_time;
56463 - atomic_t s_mb_lost_chunks;
56464 - atomic_t s_mb_preallocated;
56465 - atomic_t s_mb_discarded;
56466 + atomic_unchecked_t s_mb_lost_chunks;
56467 + atomic_unchecked_t s_mb_preallocated;
56468 + atomic_unchecked_t s_mb_discarded;
56469 atomic_t s_lock_busy;
56470
56471 /* locality groups */
56472 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56473 index 59c6750..a549154 100644
56474 --- a/fs/ext4/mballoc.c
56475 +++ b/fs/ext4/mballoc.c
56476 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56477 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56478
56479 if (EXT4_SB(sb)->s_mb_stats)
56480 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56481 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56482
56483 break;
56484 }
56485 @@ -2170,7 +2170,7 @@ repeat:
56486 ac->ac_status = AC_STATUS_CONTINUE;
56487 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56488 cr = 3;
56489 - atomic_inc(&sbi->s_mb_lost_chunks);
56490 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56491 goto repeat;
56492 }
56493 }
56494 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
56495 if (sbi->s_mb_stats) {
56496 ext4_msg(sb, KERN_INFO,
56497 "mballoc: %u blocks %u reqs (%u success)",
56498 - atomic_read(&sbi->s_bal_allocated),
56499 - atomic_read(&sbi->s_bal_reqs),
56500 - atomic_read(&sbi->s_bal_success));
56501 + atomic_read_unchecked(&sbi->s_bal_allocated),
56502 + atomic_read_unchecked(&sbi->s_bal_reqs),
56503 + atomic_read_unchecked(&sbi->s_bal_success));
56504 ext4_msg(sb, KERN_INFO,
56505 "mballoc: %u extents scanned, %u goal hits, "
56506 "%u 2^N hits, %u breaks, %u lost",
56507 - atomic_read(&sbi->s_bal_ex_scanned),
56508 - atomic_read(&sbi->s_bal_goals),
56509 - atomic_read(&sbi->s_bal_2orders),
56510 - atomic_read(&sbi->s_bal_breaks),
56511 - atomic_read(&sbi->s_mb_lost_chunks));
56512 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56513 + atomic_read_unchecked(&sbi->s_bal_goals),
56514 + atomic_read_unchecked(&sbi->s_bal_2orders),
56515 + atomic_read_unchecked(&sbi->s_bal_breaks),
56516 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56517 ext4_msg(sb, KERN_INFO,
56518 "mballoc: %lu generated and it took %Lu",
56519 sbi->s_mb_buddies_generated,
56520 sbi->s_mb_generation_time);
56521 ext4_msg(sb, KERN_INFO,
56522 "mballoc: %u preallocated, %u discarded",
56523 - atomic_read(&sbi->s_mb_preallocated),
56524 - atomic_read(&sbi->s_mb_discarded));
56525 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56526 + atomic_read_unchecked(&sbi->s_mb_discarded));
56527 }
56528
56529 free_percpu(sbi->s_locality_groups);
56530 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56531 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56532
56533 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56534 - atomic_inc(&sbi->s_bal_reqs);
56535 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56536 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56537 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56538 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56539 - atomic_inc(&sbi->s_bal_success);
56540 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56541 + atomic_inc_unchecked(&sbi->s_bal_success);
56542 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56543 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56544 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56545 - atomic_inc(&sbi->s_bal_goals);
56546 + atomic_inc_unchecked(&sbi->s_bal_goals);
56547 if (ac->ac_found > sbi->s_mb_max_to_scan)
56548 - atomic_inc(&sbi->s_bal_breaks);
56549 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56550 }
56551
56552 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56553 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56554 trace_ext4_mb_new_inode_pa(ac, pa);
56555
56556 ext4_mb_use_inode_pa(ac, pa);
56557 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56558 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56559
56560 ei = EXT4_I(ac->ac_inode);
56561 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56562 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56563 trace_ext4_mb_new_group_pa(ac, pa);
56564
56565 ext4_mb_use_group_pa(ac, pa);
56566 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56567 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56568
56569 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56570 lg = ac->ac_lg;
56571 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56572 * from the bitmap and continue.
56573 */
56574 }
56575 - atomic_add(free, &sbi->s_mb_discarded);
56576 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56577
56578 return err;
56579 }
56580 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56581 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56582 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56583 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56584 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56585 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56586 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56587
56588 return 0;
56589 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56590 index 214461e..3614c89 100644
56591 --- a/fs/ext4/mmp.c
56592 +++ b/fs/ext4/mmp.c
56593 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56594 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56595 const char *function, unsigned int line, const char *msg)
56596 {
56597 - __ext4_warning(sb, function, line, msg);
56598 + __ext4_warning(sb, function, line, "%s", msg);
56599 __ext4_warning(sb, function, line,
56600 "MMP failure info: last update time: %llu, last update "
56601 "node: %s, last update device: %s\n",
56602 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
56603 index 49d3c01..9579efd 100644
56604 --- a/fs/ext4/resize.c
56605 +++ b/fs/ext4/resize.c
56606 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
56607 ext4_fsblk_t end = start + input->blocks_count;
56608 ext4_group_t group = input->group;
56609 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
56610 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
56611 - ext4_fsblk_t metaend = start + overhead;
56612 + unsigned overhead;
56613 + ext4_fsblk_t metaend;
56614 struct buffer_head *bh = NULL;
56615 ext4_grpblk_t free_blocks_count, offset;
56616 int err = -EINVAL;
56617
56618 + if (group != sbi->s_groups_count) {
56619 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
56620 + input->group, sbi->s_groups_count);
56621 + return -EINVAL;
56622 + }
56623 +
56624 + overhead = ext4_group_overhead_blocks(sb, group);
56625 + metaend = start + overhead;
56626 input->free_blocks_count = free_blocks_count =
56627 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
56628
56629 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
56630 free_blocks_count, input->reserved_blocks);
56631
56632 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
56633 - if (group != sbi->s_groups_count)
56634 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
56635 - input->group, sbi->s_groups_count);
56636 - else if (offset != 0)
56637 + if (offset != 0)
56638 ext4_warning(sb, "Last group not full");
56639 else if (input->reserved_blocks > input->blocks_count / 5)
56640 ext4_warning(sb, "Reserved blocks too high (%u)",
56641 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56642 index 3f7c39e..227f24f 100644
56643 --- a/fs/ext4/super.c
56644 +++ b/fs/ext4/super.c
56645 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56646 }
56647
56648 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56649 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56650 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56651 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56652
56653 #ifdef CONFIG_QUOTA
56654 @@ -2372,7 +2372,7 @@ struct ext4_attr {
56655 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
56656 const char *, size_t);
56657 int offset;
56658 -};
56659 +} __do_const;
56660
56661 static int parse_strtoull(const char *buf,
56662 unsigned long long max, unsigned long long *value)
56663 diff --git a/fs/fcntl.c b/fs/fcntl.c
56664 index 6599222..e7bf0de 100644
56665 --- a/fs/fcntl.c
56666 +++ b/fs/fcntl.c
56667 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56668 if (err)
56669 return err;
56670
56671 + if (gr_handle_chroot_fowner(pid, type))
56672 + return -ENOENT;
56673 + if (gr_check_protected_task_fowner(pid, type))
56674 + return -EACCES;
56675 +
56676 f_modown(filp, pid, type, force);
56677 return 0;
56678 }
56679 diff --git a/fs/fhandle.c b/fs/fhandle.c
56680 index 999ff5c..41f4109 100644
56681 --- a/fs/fhandle.c
56682 +++ b/fs/fhandle.c
56683 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56684 } else
56685 retval = 0;
56686 /* copy the mount id */
56687 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56688 - sizeof(*mnt_id)) ||
56689 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56690 copy_to_user(ufh, handle,
56691 sizeof(struct file_handle) + handle_bytes))
56692 retval = -EFAULT;
56693 diff --git a/fs/file.c b/fs/file.c
56694 index 4a78f98..9447397 100644
56695 --- a/fs/file.c
56696 +++ b/fs/file.c
56697 @@ -16,6 +16,7 @@
56698 #include <linux/slab.h>
56699 #include <linux/vmalloc.h>
56700 #include <linux/file.h>
56701 +#include <linux/security.h>
56702 #include <linux/fdtable.h>
56703 #include <linux/bitops.h>
56704 #include <linux/interrupt.h>
56705 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56706 if (!file)
56707 return __close_fd(files, fd);
56708
56709 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56710 if (fd >= rlimit(RLIMIT_NOFILE))
56711 return -EBADF;
56712
56713 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56714 if (unlikely(oldfd == newfd))
56715 return -EINVAL;
56716
56717 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56718 if (newfd >= rlimit(RLIMIT_NOFILE))
56719 return -EBADF;
56720
56721 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56722 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56723 {
56724 int err;
56725 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56726 if (from >= rlimit(RLIMIT_NOFILE))
56727 return -EINVAL;
56728 err = alloc_fd(from, flags);
56729 diff --git a/fs/filesystems.c b/fs/filesystems.c
56730 index 92567d9..fcd8cbf 100644
56731 --- a/fs/filesystems.c
56732 +++ b/fs/filesystems.c
56733 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56734 int len = dot ? dot - name : strlen(name);
56735
56736 fs = __get_fs_type(name, len);
56737 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56738 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56739 +#else
56740 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56741 +#endif
56742 fs = __get_fs_type(name, len);
56743
56744 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56745 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56746 index d8ac61d..79a36f0 100644
56747 --- a/fs/fs_struct.c
56748 +++ b/fs/fs_struct.c
56749 @@ -4,6 +4,7 @@
56750 #include <linux/path.h>
56751 #include <linux/slab.h>
56752 #include <linux/fs_struct.h>
56753 +#include <linux/grsecurity.h>
56754 #include "internal.h"
56755
56756 /*
56757 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56758 write_seqcount_begin(&fs->seq);
56759 old_root = fs->root;
56760 fs->root = *path;
56761 + gr_set_chroot_entries(current, path);
56762 write_seqcount_end(&fs->seq);
56763 spin_unlock(&fs->lock);
56764 if (old_root.dentry)
56765 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56766 int hits = 0;
56767 spin_lock(&fs->lock);
56768 write_seqcount_begin(&fs->seq);
56769 + /* this root replacement is only done by pivot_root,
56770 + leave grsec's chroot tagging alone for this task
56771 + so that a pivoted root isn't treated as a chroot
56772 + */
56773 hits += replace_path(&fs->root, old_root, new_root);
56774 hits += replace_path(&fs->pwd, old_root, new_root);
56775 write_seqcount_end(&fs->seq);
56776 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56777 task_lock(tsk);
56778 spin_lock(&fs->lock);
56779 tsk->fs = NULL;
56780 - kill = !--fs->users;
56781 + gr_clear_chroot_entries(tsk);
56782 + kill = !atomic_dec_return(&fs->users);
56783 spin_unlock(&fs->lock);
56784 task_unlock(tsk);
56785 if (kill)
56786 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56787 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56788 /* We don't need to lock fs - think why ;-) */
56789 if (fs) {
56790 - fs->users = 1;
56791 + atomic_set(&fs->users, 1);
56792 fs->in_exec = 0;
56793 spin_lock_init(&fs->lock);
56794 seqcount_init(&fs->seq);
56795 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56796 spin_lock(&old->lock);
56797 fs->root = old->root;
56798 path_get(&fs->root);
56799 + /* instead of calling gr_set_chroot_entries here,
56800 + we call it from every caller of this function
56801 + */
56802 fs->pwd = old->pwd;
56803 path_get(&fs->pwd);
56804 spin_unlock(&old->lock);
56805 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56806
56807 task_lock(current);
56808 spin_lock(&fs->lock);
56809 - kill = !--fs->users;
56810 + kill = !atomic_dec_return(&fs->users);
56811 current->fs = new_fs;
56812 + gr_set_chroot_entries(current, &new_fs->root);
56813 spin_unlock(&fs->lock);
56814 task_unlock(current);
56815
56816 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56817
56818 int current_umask(void)
56819 {
56820 - return current->fs->umask;
56821 + return current->fs->umask | gr_acl_umask();
56822 }
56823 EXPORT_SYMBOL(current_umask);
56824
56825 /* to be mentioned only in INIT_TASK */
56826 struct fs_struct init_fs = {
56827 - .users = 1,
56828 + .users = ATOMIC_INIT(1),
56829 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56830 .seq = SEQCNT_ZERO,
56831 .umask = 0022,
56832 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56833 index e2cba1f..20319c5 100644
56834 --- a/fs/fscache/cookie.c
56835 +++ b/fs/fscache/cookie.c
56836 @@ -19,7 +19,7 @@
56837
56838 struct kmem_cache *fscache_cookie_jar;
56839
56840 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56841 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56842
56843 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56844 static int fscache_alloc_object(struct fscache_cache *cache,
56845 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56846 parent ? (char *) parent->def->name : "<no-parent>",
56847 def->name, netfs_data);
56848
56849 - fscache_stat(&fscache_n_acquires);
56850 + fscache_stat_unchecked(&fscache_n_acquires);
56851
56852 /* if there's no parent cookie, then we don't create one here either */
56853 if (!parent) {
56854 - fscache_stat(&fscache_n_acquires_null);
56855 + fscache_stat_unchecked(&fscache_n_acquires_null);
56856 _leave(" [no parent]");
56857 return NULL;
56858 }
56859 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56860 /* allocate and initialise a cookie */
56861 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56862 if (!cookie) {
56863 - fscache_stat(&fscache_n_acquires_oom);
56864 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56865 _leave(" [ENOMEM]");
56866 return NULL;
56867 }
56868 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56869
56870 switch (cookie->def->type) {
56871 case FSCACHE_COOKIE_TYPE_INDEX:
56872 - fscache_stat(&fscache_n_cookie_index);
56873 + fscache_stat_unchecked(&fscache_n_cookie_index);
56874 break;
56875 case FSCACHE_COOKIE_TYPE_DATAFILE:
56876 - fscache_stat(&fscache_n_cookie_data);
56877 + fscache_stat_unchecked(&fscache_n_cookie_data);
56878 break;
56879 default:
56880 - fscache_stat(&fscache_n_cookie_special);
56881 + fscache_stat_unchecked(&fscache_n_cookie_special);
56882 break;
56883 }
56884
56885 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56886 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56887 atomic_dec(&parent->n_children);
56888 __fscache_cookie_put(cookie);
56889 - fscache_stat(&fscache_n_acquires_nobufs);
56890 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56891 _leave(" = NULL");
56892 return NULL;
56893 }
56894 }
56895
56896 - fscache_stat(&fscache_n_acquires_ok);
56897 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56898 _leave(" = %p", cookie);
56899 return cookie;
56900 }
56901 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56902 cache = fscache_select_cache_for_object(cookie->parent);
56903 if (!cache) {
56904 up_read(&fscache_addremove_sem);
56905 - fscache_stat(&fscache_n_acquires_no_cache);
56906 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56907 _leave(" = -ENOMEDIUM [no cache]");
56908 return -ENOMEDIUM;
56909 }
56910 @@ -255,14 +255,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56911 object = cache->ops->alloc_object(cache, cookie);
56912 fscache_stat_d(&fscache_n_cop_alloc_object);
56913 if (IS_ERR(object)) {
56914 - fscache_stat(&fscache_n_object_no_alloc);
56915 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56916 ret = PTR_ERR(object);
56917 goto error;
56918 }
56919
56920 - fscache_stat(&fscache_n_object_alloc);
56921 + fscache_stat_unchecked(&fscache_n_object_alloc);
56922
56923 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56924 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56925
56926 _debug("ALLOC OBJ%x: %s {%lx}",
56927 object->debug_id, cookie->def->name, object->events);
56928 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56929
56930 _enter("{%s}", cookie->def->name);
56931
56932 - fscache_stat(&fscache_n_invalidates);
56933 + fscache_stat_unchecked(&fscache_n_invalidates);
56934
56935 /* Only permit invalidation of data files. Invalidating an index will
56936 * require the caller to release all its attachments to the tree rooted
56937 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56938 {
56939 struct fscache_object *object;
56940
56941 - fscache_stat(&fscache_n_updates);
56942 + fscache_stat_unchecked(&fscache_n_updates);
56943
56944 if (!cookie) {
56945 - fscache_stat(&fscache_n_updates_null);
56946 + fscache_stat_unchecked(&fscache_n_updates_null);
56947 _leave(" [no cookie]");
56948 return;
56949 }
56950 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56951 struct fscache_object *object;
56952 unsigned long event;
56953
56954 - fscache_stat(&fscache_n_relinquishes);
56955 + fscache_stat_unchecked(&fscache_n_relinquishes);
56956 if (retire)
56957 - fscache_stat(&fscache_n_relinquishes_retire);
56958 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56959
56960 if (!cookie) {
56961 - fscache_stat(&fscache_n_relinquishes_null);
56962 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56963 _leave(" [no cookie]");
56964 return;
56965 }
56966 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56967
56968 /* wait for the cookie to finish being instantiated (or to fail) */
56969 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
56970 - fscache_stat(&fscache_n_relinquishes_waitcrt);
56971 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
56972 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
56973 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
56974 }
56975 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56976 index ee38fef..0a326d4 100644
56977 --- a/fs/fscache/internal.h
56978 +++ b/fs/fscache/internal.h
56979 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
56980 * stats.c
56981 */
56982 #ifdef CONFIG_FSCACHE_STATS
56983 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56984 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56985 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56986 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56987
56988 -extern atomic_t fscache_n_op_pend;
56989 -extern atomic_t fscache_n_op_run;
56990 -extern atomic_t fscache_n_op_enqueue;
56991 -extern atomic_t fscache_n_op_deferred_release;
56992 -extern atomic_t fscache_n_op_release;
56993 -extern atomic_t fscache_n_op_gc;
56994 -extern atomic_t fscache_n_op_cancelled;
56995 -extern atomic_t fscache_n_op_rejected;
56996 +extern atomic_unchecked_t fscache_n_op_pend;
56997 +extern atomic_unchecked_t fscache_n_op_run;
56998 +extern atomic_unchecked_t fscache_n_op_enqueue;
56999 +extern atomic_unchecked_t fscache_n_op_deferred_release;
57000 +extern atomic_unchecked_t fscache_n_op_release;
57001 +extern atomic_unchecked_t fscache_n_op_gc;
57002 +extern atomic_unchecked_t fscache_n_op_cancelled;
57003 +extern atomic_unchecked_t fscache_n_op_rejected;
57004
57005 -extern atomic_t fscache_n_attr_changed;
57006 -extern atomic_t fscache_n_attr_changed_ok;
57007 -extern atomic_t fscache_n_attr_changed_nobufs;
57008 -extern atomic_t fscache_n_attr_changed_nomem;
57009 -extern atomic_t fscache_n_attr_changed_calls;
57010 +extern atomic_unchecked_t fscache_n_attr_changed;
57011 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
57012 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
57013 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
57014 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
57015
57016 -extern atomic_t fscache_n_allocs;
57017 -extern atomic_t fscache_n_allocs_ok;
57018 -extern atomic_t fscache_n_allocs_wait;
57019 -extern atomic_t fscache_n_allocs_nobufs;
57020 -extern atomic_t fscache_n_allocs_intr;
57021 -extern atomic_t fscache_n_allocs_object_dead;
57022 -extern atomic_t fscache_n_alloc_ops;
57023 -extern atomic_t fscache_n_alloc_op_waits;
57024 +extern atomic_unchecked_t fscache_n_allocs;
57025 +extern atomic_unchecked_t fscache_n_allocs_ok;
57026 +extern atomic_unchecked_t fscache_n_allocs_wait;
57027 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
57028 +extern atomic_unchecked_t fscache_n_allocs_intr;
57029 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
57030 +extern atomic_unchecked_t fscache_n_alloc_ops;
57031 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
57032
57033 -extern atomic_t fscache_n_retrievals;
57034 -extern atomic_t fscache_n_retrievals_ok;
57035 -extern atomic_t fscache_n_retrievals_wait;
57036 -extern atomic_t fscache_n_retrievals_nodata;
57037 -extern atomic_t fscache_n_retrievals_nobufs;
57038 -extern atomic_t fscache_n_retrievals_intr;
57039 -extern atomic_t fscache_n_retrievals_nomem;
57040 -extern atomic_t fscache_n_retrievals_object_dead;
57041 -extern atomic_t fscache_n_retrieval_ops;
57042 -extern atomic_t fscache_n_retrieval_op_waits;
57043 +extern atomic_unchecked_t fscache_n_retrievals;
57044 +extern atomic_unchecked_t fscache_n_retrievals_ok;
57045 +extern atomic_unchecked_t fscache_n_retrievals_wait;
57046 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
57047 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
57048 +extern atomic_unchecked_t fscache_n_retrievals_intr;
57049 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
57050 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
57051 +extern atomic_unchecked_t fscache_n_retrieval_ops;
57052 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
57053
57054 -extern atomic_t fscache_n_stores;
57055 -extern atomic_t fscache_n_stores_ok;
57056 -extern atomic_t fscache_n_stores_again;
57057 -extern atomic_t fscache_n_stores_nobufs;
57058 -extern atomic_t fscache_n_stores_oom;
57059 -extern atomic_t fscache_n_store_ops;
57060 -extern atomic_t fscache_n_store_calls;
57061 -extern atomic_t fscache_n_store_pages;
57062 -extern atomic_t fscache_n_store_radix_deletes;
57063 -extern atomic_t fscache_n_store_pages_over_limit;
57064 +extern atomic_unchecked_t fscache_n_stores;
57065 +extern atomic_unchecked_t fscache_n_stores_ok;
57066 +extern atomic_unchecked_t fscache_n_stores_again;
57067 +extern atomic_unchecked_t fscache_n_stores_nobufs;
57068 +extern atomic_unchecked_t fscache_n_stores_oom;
57069 +extern atomic_unchecked_t fscache_n_store_ops;
57070 +extern atomic_unchecked_t fscache_n_store_calls;
57071 +extern atomic_unchecked_t fscache_n_store_pages;
57072 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
57073 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
57074
57075 -extern atomic_t fscache_n_store_vmscan_not_storing;
57076 -extern atomic_t fscache_n_store_vmscan_gone;
57077 -extern atomic_t fscache_n_store_vmscan_busy;
57078 -extern atomic_t fscache_n_store_vmscan_cancelled;
57079 -extern atomic_t fscache_n_store_vmscan_wait;
57080 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57081 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
57082 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
57083 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57084 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
57085
57086 -extern atomic_t fscache_n_marks;
57087 -extern atomic_t fscache_n_uncaches;
57088 +extern atomic_unchecked_t fscache_n_marks;
57089 +extern atomic_unchecked_t fscache_n_uncaches;
57090
57091 -extern atomic_t fscache_n_acquires;
57092 -extern atomic_t fscache_n_acquires_null;
57093 -extern atomic_t fscache_n_acquires_no_cache;
57094 -extern atomic_t fscache_n_acquires_ok;
57095 -extern atomic_t fscache_n_acquires_nobufs;
57096 -extern atomic_t fscache_n_acquires_oom;
57097 +extern atomic_unchecked_t fscache_n_acquires;
57098 +extern atomic_unchecked_t fscache_n_acquires_null;
57099 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
57100 +extern atomic_unchecked_t fscache_n_acquires_ok;
57101 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
57102 +extern atomic_unchecked_t fscache_n_acquires_oom;
57103
57104 -extern atomic_t fscache_n_invalidates;
57105 -extern atomic_t fscache_n_invalidates_run;
57106 +extern atomic_unchecked_t fscache_n_invalidates;
57107 +extern atomic_unchecked_t fscache_n_invalidates_run;
57108
57109 -extern atomic_t fscache_n_updates;
57110 -extern atomic_t fscache_n_updates_null;
57111 -extern atomic_t fscache_n_updates_run;
57112 +extern atomic_unchecked_t fscache_n_updates;
57113 +extern atomic_unchecked_t fscache_n_updates_null;
57114 +extern atomic_unchecked_t fscache_n_updates_run;
57115
57116 -extern atomic_t fscache_n_relinquishes;
57117 -extern atomic_t fscache_n_relinquishes_null;
57118 -extern atomic_t fscache_n_relinquishes_waitcrt;
57119 -extern atomic_t fscache_n_relinquishes_retire;
57120 +extern atomic_unchecked_t fscache_n_relinquishes;
57121 +extern atomic_unchecked_t fscache_n_relinquishes_null;
57122 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57123 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
57124
57125 -extern atomic_t fscache_n_cookie_index;
57126 -extern atomic_t fscache_n_cookie_data;
57127 -extern atomic_t fscache_n_cookie_special;
57128 +extern atomic_unchecked_t fscache_n_cookie_index;
57129 +extern atomic_unchecked_t fscache_n_cookie_data;
57130 +extern atomic_unchecked_t fscache_n_cookie_special;
57131
57132 -extern atomic_t fscache_n_object_alloc;
57133 -extern atomic_t fscache_n_object_no_alloc;
57134 -extern atomic_t fscache_n_object_lookups;
57135 -extern atomic_t fscache_n_object_lookups_negative;
57136 -extern atomic_t fscache_n_object_lookups_positive;
57137 -extern atomic_t fscache_n_object_lookups_timed_out;
57138 -extern atomic_t fscache_n_object_created;
57139 -extern atomic_t fscache_n_object_avail;
57140 -extern atomic_t fscache_n_object_dead;
57141 +extern atomic_unchecked_t fscache_n_object_alloc;
57142 +extern atomic_unchecked_t fscache_n_object_no_alloc;
57143 +extern atomic_unchecked_t fscache_n_object_lookups;
57144 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
57145 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
57146 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
57147 +extern atomic_unchecked_t fscache_n_object_created;
57148 +extern atomic_unchecked_t fscache_n_object_avail;
57149 +extern atomic_unchecked_t fscache_n_object_dead;
57150
57151 -extern atomic_t fscache_n_checkaux_none;
57152 -extern atomic_t fscache_n_checkaux_okay;
57153 -extern atomic_t fscache_n_checkaux_update;
57154 -extern atomic_t fscache_n_checkaux_obsolete;
57155 +extern atomic_unchecked_t fscache_n_checkaux_none;
57156 +extern atomic_unchecked_t fscache_n_checkaux_okay;
57157 +extern atomic_unchecked_t fscache_n_checkaux_update;
57158 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
57159
57160 extern atomic_t fscache_n_cop_alloc_object;
57161 extern atomic_t fscache_n_cop_lookup_object;
57162 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
57163 atomic_inc(stat);
57164 }
57165
57166 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
57167 +{
57168 + atomic_inc_unchecked(stat);
57169 +}
57170 +
57171 static inline void fscache_stat_d(atomic_t *stat)
57172 {
57173 atomic_dec(stat);
57174 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
57175
57176 #define __fscache_stat(stat) (NULL)
57177 #define fscache_stat(stat) do {} while (0)
57178 +#define fscache_stat_unchecked(stat) do {} while (0)
57179 #define fscache_stat_d(stat) do {} while (0)
57180 #endif
57181
57182 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
57183 index 50d41c1..10ee117 100644
57184 --- a/fs/fscache/object.c
57185 +++ b/fs/fscache/object.c
57186 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57187 /* Invalidate an object on disk */
57188 case FSCACHE_OBJECT_INVALIDATING:
57189 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
57190 - fscache_stat(&fscache_n_invalidates_run);
57191 + fscache_stat_unchecked(&fscache_n_invalidates_run);
57192 fscache_stat(&fscache_n_cop_invalidate_object);
57193 fscache_invalidate_object(object);
57194 fscache_stat_d(&fscache_n_cop_invalidate_object);
57195 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57196 /* update the object metadata on disk */
57197 case FSCACHE_OBJECT_UPDATING:
57198 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
57199 - fscache_stat(&fscache_n_updates_run);
57200 + fscache_stat_unchecked(&fscache_n_updates_run);
57201 fscache_stat(&fscache_n_cop_update_object);
57202 object->cache->ops->update_object(object);
57203 fscache_stat_d(&fscache_n_cop_update_object);
57204 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57205 spin_lock(&object->lock);
57206 object->state = FSCACHE_OBJECT_DEAD;
57207 spin_unlock(&object->lock);
57208 - fscache_stat(&fscache_n_object_dead);
57209 + fscache_stat_unchecked(&fscache_n_object_dead);
57210 goto terminal_transit;
57211
57212 /* handle the parent cache of this object being withdrawn from
57213 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57214 spin_lock(&object->lock);
57215 object->state = FSCACHE_OBJECT_DEAD;
57216 spin_unlock(&object->lock);
57217 - fscache_stat(&fscache_n_object_dead);
57218 + fscache_stat_unchecked(&fscache_n_object_dead);
57219 goto terminal_transit;
57220
57221 /* complain about the object being woken up once it is
57222 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
57223 parent->cookie->def->name, cookie->def->name,
57224 object->cache->tag->name);
57225
57226 - fscache_stat(&fscache_n_object_lookups);
57227 + fscache_stat_unchecked(&fscache_n_object_lookups);
57228 fscache_stat(&fscache_n_cop_lookup_object);
57229 ret = object->cache->ops->lookup_object(object);
57230 fscache_stat_d(&fscache_n_cop_lookup_object);
57231 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
57232 if (ret == -ETIMEDOUT) {
57233 /* probably stuck behind another object, so move this one to
57234 * the back of the queue */
57235 - fscache_stat(&fscache_n_object_lookups_timed_out);
57236 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
57237 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
57238 }
57239
57240 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
57241
57242 spin_lock(&object->lock);
57243 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
57244 - fscache_stat(&fscache_n_object_lookups_negative);
57245 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
57246
57247 /* transit here to allow write requests to begin stacking up
57248 * and read requests to begin returning ENODATA */
57249 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
57250 * result, in which case there may be data available */
57251 spin_lock(&object->lock);
57252 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
57253 - fscache_stat(&fscache_n_object_lookups_positive);
57254 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
57255
57256 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
57257
57258 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
57259 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
57260 } else {
57261 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
57262 - fscache_stat(&fscache_n_object_created);
57263 + fscache_stat_unchecked(&fscache_n_object_created);
57264
57265 object->state = FSCACHE_OBJECT_AVAILABLE;
57266 spin_unlock(&object->lock);
57267 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
57268 fscache_enqueue_dependents(object);
57269
57270 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
57271 - fscache_stat(&fscache_n_object_avail);
57272 + fscache_stat_unchecked(&fscache_n_object_avail);
57273
57274 _leave("");
57275 }
57276 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57277 enum fscache_checkaux result;
57278
57279 if (!object->cookie->def->check_aux) {
57280 - fscache_stat(&fscache_n_checkaux_none);
57281 + fscache_stat_unchecked(&fscache_n_checkaux_none);
57282 return FSCACHE_CHECKAUX_OKAY;
57283 }
57284
57285 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57286 switch (result) {
57287 /* entry okay as is */
57288 case FSCACHE_CHECKAUX_OKAY:
57289 - fscache_stat(&fscache_n_checkaux_okay);
57290 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
57291 break;
57292
57293 /* entry requires update */
57294 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
57295 - fscache_stat(&fscache_n_checkaux_update);
57296 + fscache_stat_unchecked(&fscache_n_checkaux_update);
57297 break;
57298
57299 /* entry requires deletion */
57300 case FSCACHE_CHECKAUX_OBSOLETE:
57301 - fscache_stat(&fscache_n_checkaux_obsolete);
57302 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
57303 break;
57304
57305 default:
57306 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
57307 index 762a9ec..2023284 100644
57308 --- a/fs/fscache/operation.c
57309 +++ b/fs/fscache/operation.c
57310 @@ -17,7 +17,7 @@
57311 #include <linux/slab.h>
57312 #include "internal.h"
57313
57314 -atomic_t fscache_op_debug_id;
57315 +atomic_unchecked_t fscache_op_debug_id;
57316 EXPORT_SYMBOL(fscache_op_debug_id);
57317
57318 /**
57319 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
57320 ASSERTCMP(atomic_read(&op->usage), >, 0);
57321 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
57322
57323 - fscache_stat(&fscache_n_op_enqueue);
57324 + fscache_stat_unchecked(&fscache_n_op_enqueue);
57325 switch (op->flags & FSCACHE_OP_TYPE) {
57326 case FSCACHE_OP_ASYNC:
57327 _debug("queue async");
57328 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
57329 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
57330 if (op->processor)
57331 fscache_enqueue_operation(op);
57332 - fscache_stat(&fscache_n_op_run);
57333 + fscache_stat_unchecked(&fscache_n_op_run);
57334 }
57335
57336 /*
57337 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57338 if (object->n_in_progress > 0) {
57339 atomic_inc(&op->usage);
57340 list_add_tail(&op->pend_link, &object->pending_ops);
57341 - fscache_stat(&fscache_n_op_pend);
57342 + fscache_stat_unchecked(&fscache_n_op_pend);
57343 } else if (!list_empty(&object->pending_ops)) {
57344 atomic_inc(&op->usage);
57345 list_add_tail(&op->pend_link, &object->pending_ops);
57346 - fscache_stat(&fscache_n_op_pend);
57347 + fscache_stat_unchecked(&fscache_n_op_pend);
57348 fscache_start_operations(object);
57349 } else {
57350 ASSERTCMP(object->n_in_progress, ==, 0);
57351 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57352 object->n_exclusive++; /* reads and writes must wait */
57353 atomic_inc(&op->usage);
57354 list_add_tail(&op->pend_link, &object->pending_ops);
57355 - fscache_stat(&fscache_n_op_pend);
57356 + fscache_stat_unchecked(&fscache_n_op_pend);
57357 ret = 0;
57358 } else {
57359 /* If we're in any other state, there must have been an I/O
57360 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
57361 if (object->n_exclusive > 0) {
57362 atomic_inc(&op->usage);
57363 list_add_tail(&op->pend_link, &object->pending_ops);
57364 - fscache_stat(&fscache_n_op_pend);
57365 + fscache_stat_unchecked(&fscache_n_op_pend);
57366 } else if (!list_empty(&object->pending_ops)) {
57367 atomic_inc(&op->usage);
57368 list_add_tail(&op->pend_link, &object->pending_ops);
57369 - fscache_stat(&fscache_n_op_pend);
57370 + fscache_stat_unchecked(&fscache_n_op_pend);
57371 fscache_start_operations(object);
57372 } else {
57373 ASSERTCMP(object->n_exclusive, ==, 0);
57374 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
57375 object->n_ops++;
57376 atomic_inc(&op->usage);
57377 list_add_tail(&op->pend_link, &object->pending_ops);
57378 - fscache_stat(&fscache_n_op_pend);
57379 + fscache_stat_unchecked(&fscache_n_op_pend);
57380 ret = 0;
57381 } else if (object->state == FSCACHE_OBJECT_DYING ||
57382 object->state == FSCACHE_OBJECT_LC_DYING ||
57383 object->state == FSCACHE_OBJECT_WITHDRAWING) {
57384 - fscache_stat(&fscache_n_op_rejected);
57385 + fscache_stat_unchecked(&fscache_n_op_rejected);
57386 op->state = FSCACHE_OP_ST_CANCELLED;
57387 ret = -ENOBUFS;
57388 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
57389 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
57390 ret = -EBUSY;
57391 if (op->state == FSCACHE_OP_ST_PENDING) {
57392 ASSERT(!list_empty(&op->pend_link));
57393 - fscache_stat(&fscache_n_op_cancelled);
57394 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57395 list_del_init(&op->pend_link);
57396 if (do_cancel)
57397 do_cancel(op);
57398 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
57399 while (!list_empty(&object->pending_ops)) {
57400 op = list_entry(object->pending_ops.next,
57401 struct fscache_operation, pend_link);
57402 - fscache_stat(&fscache_n_op_cancelled);
57403 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57404 list_del_init(&op->pend_link);
57405
57406 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
57407 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
57408 op->state, ==, FSCACHE_OP_ST_CANCELLED);
57409 op->state = FSCACHE_OP_ST_DEAD;
57410
57411 - fscache_stat(&fscache_n_op_release);
57412 + fscache_stat_unchecked(&fscache_n_op_release);
57413
57414 if (op->release) {
57415 op->release(op);
57416 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
57417 * lock, and defer it otherwise */
57418 if (!spin_trylock(&object->lock)) {
57419 _debug("defer put");
57420 - fscache_stat(&fscache_n_op_deferred_release);
57421 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
57422
57423 cache = object->cache;
57424 spin_lock(&cache->op_gc_list_lock);
57425 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
57426
57427 _debug("GC DEFERRED REL OBJ%x OP%x",
57428 object->debug_id, op->debug_id);
57429 - fscache_stat(&fscache_n_op_gc);
57430 + fscache_stat_unchecked(&fscache_n_op_gc);
57431
57432 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57433 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57434 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57435 index ff000e5..c44ec6d 100644
57436 --- a/fs/fscache/page.c
57437 +++ b/fs/fscache/page.c
57438 @@ -61,7 +61,7 @@ try_again:
57439 val = radix_tree_lookup(&cookie->stores, page->index);
57440 if (!val) {
57441 rcu_read_unlock();
57442 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57443 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57444 __fscache_uncache_page(cookie, page);
57445 return true;
57446 }
57447 @@ -91,11 +91,11 @@ try_again:
57448 spin_unlock(&cookie->stores_lock);
57449
57450 if (xpage) {
57451 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57452 - fscache_stat(&fscache_n_store_radix_deletes);
57453 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57454 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57455 ASSERTCMP(xpage, ==, page);
57456 } else {
57457 - fscache_stat(&fscache_n_store_vmscan_gone);
57458 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57459 }
57460
57461 wake_up_bit(&cookie->flags, 0);
57462 @@ -110,11 +110,11 @@ page_busy:
57463 * sleeping on memory allocation, so we may need to impose a timeout
57464 * too. */
57465 if (!(gfp & __GFP_WAIT)) {
57466 - fscache_stat(&fscache_n_store_vmscan_busy);
57467 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57468 return false;
57469 }
57470
57471 - fscache_stat(&fscache_n_store_vmscan_wait);
57472 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57473 __fscache_wait_on_page_write(cookie, page);
57474 gfp &= ~__GFP_WAIT;
57475 goto try_again;
57476 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57477 FSCACHE_COOKIE_STORING_TAG);
57478 if (!radix_tree_tag_get(&cookie->stores, page->index,
57479 FSCACHE_COOKIE_PENDING_TAG)) {
57480 - fscache_stat(&fscache_n_store_radix_deletes);
57481 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57482 xpage = radix_tree_delete(&cookie->stores, page->index);
57483 }
57484 spin_unlock(&cookie->stores_lock);
57485 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57486
57487 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57488
57489 - fscache_stat(&fscache_n_attr_changed_calls);
57490 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57491
57492 if (fscache_object_is_active(object)) {
57493 fscache_stat(&fscache_n_cop_attr_changed);
57494 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57495
57496 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57497
57498 - fscache_stat(&fscache_n_attr_changed);
57499 + fscache_stat_unchecked(&fscache_n_attr_changed);
57500
57501 op = kzalloc(sizeof(*op), GFP_KERNEL);
57502 if (!op) {
57503 - fscache_stat(&fscache_n_attr_changed_nomem);
57504 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57505 _leave(" = -ENOMEM");
57506 return -ENOMEM;
57507 }
57508 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57509 if (fscache_submit_exclusive_op(object, op) < 0)
57510 goto nobufs;
57511 spin_unlock(&cookie->lock);
57512 - fscache_stat(&fscache_n_attr_changed_ok);
57513 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57514 fscache_put_operation(op);
57515 _leave(" = 0");
57516 return 0;
57517 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57518 nobufs:
57519 spin_unlock(&cookie->lock);
57520 kfree(op);
57521 - fscache_stat(&fscache_n_attr_changed_nobufs);
57522 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57523 _leave(" = %d", -ENOBUFS);
57524 return -ENOBUFS;
57525 }
57526 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57527 /* allocate a retrieval operation and attempt to submit it */
57528 op = kzalloc(sizeof(*op), GFP_NOIO);
57529 if (!op) {
57530 - fscache_stat(&fscache_n_retrievals_nomem);
57531 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57532 return NULL;
57533 }
57534
57535 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57536 return 0;
57537 }
57538
57539 - fscache_stat(&fscache_n_retrievals_wait);
57540 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57541
57542 jif = jiffies;
57543 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57544 fscache_wait_bit_interruptible,
57545 TASK_INTERRUPTIBLE) != 0) {
57546 - fscache_stat(&fscache_n_retrievals_intr);
57547 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57548 _leave(" = -ERESTARTSYS");
57549 return -ERESTARTSYS;
57550 }
57551 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57552 */
57553 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
57554 struct fscache_retrieval *op,
57555 - atomic_t *stat_op_waits,
57556 - atomic_t *stat_object_dead)
57557 + atomic_unchecked_t *stat_op_waits,
57558 + atomic_unchecked_t *stat_object_dead)
57559 {
57560 int ret;
57561
57562 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
57563 goto check_if_dead;
57564
57565 _debug(">>> WT");
57566 - fscache_stat(stat_op_waits);
57567 + fscache_stat_unchecked(stat_op_waits);
57568 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
57569 fscache_wait_bit_interruptible,
57570 TASK_INTERRUPTIBLE) != 0) {
57571 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
57572
57573 check_if_dead:
57574 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
57575 - fscache_stat(stat_object_dead);
57576 + fscache_stat_unchecked(stat_object_dead);
57577 _leave(" = -ENOBUFS [cancelled]");
57578 return -ENOBUFS;
57579 }
57580 if (unlikely(fscache_object_is_dead(object))) {
57581 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
57582 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
57583 - fscache_stat(stat_object_dead);
57584 + fscache_stat_unchecked(stat_object_dead);
57585 return -ENOBUFS;
57586 }
57587 return 0;
57588 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57589
57590 _enter("%p,%p,,,", cookie, page);
57591
57592 - fscache_stat(&fscache_n_retrievals);
57593 + fscache_stat_unchecked(&fscache_n_retrievals);
57594
57595 if (hlist_empty(&cookie->backing_objects))
57596 goto nobufs;
57597 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57598 goto nobufs_unlock_dec;
57599 spin_unlock(&cookie->lock);
57600
57601 - fscache_stat(&fscache_n_retrieval_ops);
57602 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57603
57604 /* pin the netfs read context in case we need to do the actual netfs
57605 * read because we've encountered a cache read failure */
57606 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57607
57608 error:
57609 if (ret == -ENOMEM)
57610 - fscache_stat(&fscache_n_retrievals_nomem);
57611 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57612 else if (ret == -ERESTARTSYS)
57613 - fscache_stat(&fscache_n_retrievals_intr);
57614 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57615 else if (ret == -ENODATA)
57616 - fscache_stat(&fscache_n_retrievals_nodata);
57617 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57618 else if (ret < 0)
57619 - fscache_stat(&fscache_n_retrievals_nobufs);
57620 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57621 else
57622 - fscache_stat(&fscache_n_retrievals_ok);
57623 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57624
57625 fscache_put_retrieval(op);
57626 _leave(" = %d", ret);
57627 @@ -467,7 +467,7 @@ nobufs_unlock:
57628 spin_unlock(&cookie->lock);
57629 kfree(op);
57630 nobufs:
57631 - fscache_stat(&fscache_n_retrievals_nobufs);
57632 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57633 _leave(" = -ENOBUFS");
57634 return -ENOBUFS;
57635 }
57636 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57637
57638 _enter("%p,,%d,,,", cookie, *nr_pages);
57639
57640 - fscache_stat(&fscache_n_retrievals);
57641 + fscache_stat_unchecked(&fscache_n_retrievals);
57642
57643 if (hlist_empty(&cookie->backing_objects))
57644 goto nobufs;
57645 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57646 goto nobufs_unlock_dec;
57647 spin_unlock(&cookie->lock);
57648
57649 - fscache_stat(&fscache_n_retrieval_ops);
57650 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57651
57652 /* pin the netfs read context in case we need to do the actual netfs
57653 * read because we've encountered a cache read failure */
57654 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57655
57656 error:
57657 if (ret == -ENOMEM)
57658 - fscache_stat(&fscache_n_retrievals_nomem);
57659 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57660 else if (ret == -ERESTARTSYS)
57661 - fscache_stat(&fscache_n_retrievals_intr);
57662 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57663 else if (ret == -ENODATA)
57664 - fscache_stat(&fscache_n_retrievals_nodata);
57665 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57666 else if (ret < 0)
57667 - fscache_stat(&fscache_n_retrievals_nobufs);
57668 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57669 else
57670 - fscache_stat(&fscache_n_retrievals_ok);
57671 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57672
57673 fscache_put_retrieval(op);
57674 _leave(" = %d", ret);
57675 @@ -591,7 +591,7 @@ nobufs_unlock:
57676 spin_unlock(&cookie->lock);
57677 kfree(op);
57678 nobufs:
57679 - fscache_stat(&fscache_n_retrievals_nobufs);
57680 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57681 _leave(" = -ENOBUFS");
57682 return -ENOBUFS;
57683 }
57684 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57685
57686 _enter("%p,%p,,,", cookie, page);
57687
57688 - fscache_stat(&fscache_n_allocs);
57689 + fscache_stat_unchecked(&fscache_n_allocs);
57690
57691 if (hlist_empty(&cookie->backing_objects))
57692 goto nobufs;
57693 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57694 goto nobufs_unlock;
57695 spin_unlock(&cookie->lock);
57696
57697 - fscache_stat(&fscache_n_alloc_ops);
57698 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57699
57700 ret = fscache_wait_for_retrieval_activation(
57701 object, op,
57702 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57703
57704 error:
57705 if (ret == -ERESTARTSYS)
57706 - fscache_stat(&fscache_n_allocs_intr);
57707 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57708 else if (ret < 0)
57709 - fscache_stat(&fscache_n_allocs_nobufs);
57710 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57711 else
57712 - fscache_stat(&fscache_n_allocs_ok);
57713 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57714
57715 fscache_put_retrieval(op);
57716 _leave(" = %d", ret);
57717 @@ -677,7 +677,7 @@ nobufs_unlock:
57718 spin_unlock(&cookie->lock);
57719 kfree(op);
57720 nobufs:
57721 - fscache_stat(&fscache_n_allocs_nobufs);
57722 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57723 _leave(" = -ENOBUFS");
57724 return -ENOBUFS;
57725 }
57726 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57727
57728 spin_lock(&cookie->stores_lock);
57729
57730 - fscache_stat(&fscache_n_store_calls);
57731 + fscache_stat_unchecked(&fscache_n_store_calls);
57732
57733 /* find a page to store */
57734 page = NULL;
57735 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57736 page = results[0];
57737 _debug("gang %d [%lx]", n, page->index);
57738 if (page->index > op->store_limit) {
57739 - fscache_stat(&fscache_n_store_pages_over_limit);
57740 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57741 goto superseded;
57742 }
57743
57744 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57745 spin_unlock(&cookie->stores_lock);
57746 spin_unlock(&object->lock);
57747
57748 - fscache_stat(&fscache_n_store_pages);
57749 + fscache_stat_unchecked(&fscache_n_store_pages);
57750 fscache_stat(&fscache_n_cop_write_page);
57751 ret = object->cache->ops->write_page(op, page);
57752 fscache_stat_d(&fscache_n_cop_write_page);
57753 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57754 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57755 ASSERT(PageFsCache(page));
57756
57757 - fscache_stat(&fscache_n_stores);
57758 + fscache_stat_unchecked(&fscache_n_stores);
57759
57760 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57761 _leave(" = -ENOBUFS [invalidating]");
57762 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57763 spin_unlock(&cookie->stores_lock);
57764 spin_unlock(&object->lock);
57765
57766 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57767 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57768 op->store_limit = object->store_limit;
57769
57770 if (fscache_submit_op(object, &op->op) < 0)
57771 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57772
57773 spin_unlock(&cookie->lock);
57774 radix_tree_preload_end();
57775 - fscache_stat(&fscache_n_store_ops);
57776 - fscache_stat(&fscache_n_stores_ok);
57777 + fscache_stat_unchecked(&fscache_n_store_ops);
57778 + fscache_stat_unchecked(&fscache_n_stores_ok);
57779
57780 /* the work queue now carries its own ref on the object */
57781 fscache_put_operation(&op->op);
57782 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57783 return 0;
57784
57785 already_queued:
57786 - fscache_stat(&fscache_n_stores_again);
57787 + fscache_stat_unchecked(&fscache_n_stores_again);
57788 already_pending:
57789 spin_unlock(&cookie->stores_lock);
57790 spin_unlock(&object->lock);
57791 spin_unlock(&cookie->lock);
57792 radix_tree_preload_end();
57793 kfree(op);
57794 - fscache_stat(&fscache_n_stores_ok);
57795 + fscache_stat_unchecked(&fscache_n_stores_ok);
57796 _leave(" = 0");
57797 return 0;
57798
57799 @@ -959,14 +959,14 @@ nobufs:
57800 spin_unlock(&cookie->lock);
57801 radix_tree_preload_end();
57802 kfree(op);
57803 - fscache_stat(&fscache_n_stores_nobufs);
57804 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57805 _leave(" = -ENOBUFS");
57806 return -ENOBUFS;
57807
57808 nomem_free:
57809 kfree(op);
57810 nomem:
57811 - fscache_stat(&fscache_n_stores_oom);
57812 + fscache_stat_unchecked(&fscache_n_stores_oom);
57813 _leave(" = -ENOMEM");
57814 return -ENOMEM;
57815 }
57816 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57817 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57818 ASSERTCMP(page, !=, NULL);
57819
57820 - fscache_stat(&fscache_n_uncaches);
57821 + fscache_stat_unchecked(&fscache_n_uncaches);
57822
57823 /* cache withdrawal may beat us to it */
57824 if (!PageFsCache(page))
57825 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57826 struct fscache_cookie *cookie = op->op.object->cookie;
57827
57828 #ifdef CONFIG_FSCACHE_STATS
57829 - atomic_inc(&fscache_n_marks);
57830 + atomic_inc_unchecked(&fscache_n_marks);
57831 #endif
57832
57833 _debug("- mark %p{%lx}", page, page->index);
57834 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57835 index 40d13c7..ddf52b9 100644
57836 --- a/fs/fscache/stats.c
57837 +++ b/fs/fscache/stats.c
57838 @@ -18,99 +18,99 @@
57839 /*
57840 * operation counters
57841 */
57842 -atomic_t fscache_n_op_pend;
57843 -atomic_t fscache_n_op_run;
57844 -atomic_t fscache_n_op_enqueue;
57845 -atomic_t fscache_n_op_requeue;
57846 -atomic_t fscache_n_op_deferred_release;
57847 -atomic_t fscache_n_op_release;
57848 -atomic_t fscache_n_op_gc;
57849 -atomic_t fscache_n_op_cancelled;
57850 -atomic_t fscache_n_op_rejected;
57851 +atomic_unchecked_t fscache_n_op_pend;
57852 +atomic_unchecked_t fscache_n_op_run;
57853 +atomic_unchecked_t fscache_n_op_enqueue;
57854 +atomic_unchecked_t fscache_n_op_requeue;
57855 +atomic_unchecked_t fscache_n_op_deferred_release;
57856 +atomic_unchecked_t fscache_n_op_release;
57857 +atomic_unchecked_t fscache_n_op_gc;
57858 +atomic_unchecked_t fscache_n_op_cancelled;
57859 +atomic_unchecked_t fscache_n_op_rejected;
57860
57861 -atomic_t fscache_n_attr_changed;
57862 -atomic_t fscache_n_attr_changed_ok;
57863 -atomic_t fscache_n_attr_changed_nobufs;
57864 -atomic_t fscache_n_attr_changed_nomem;
57865 -atomic_t fscache_n_attr_changed_calls;
57866 +atomic_unchecked_t fscache_n_attr_changed;
57867 +atomic_unchecked_t fscache_n_attr_changed_ok;
57868 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
57869 +atomic_unchecked_t fscache_n_attr_changed_nomem;
57870 +atomic_unchecked_t fscache_n_attr_changed_calls;
57871
57872 -atomic_t fscache_n_allocs;
57873 -atomic_t fscache_n_allocs_ok;
57874 -atomic_t fscache_n_allocs_wait;
57875 -atomic_t fscache_n_allocs_nobufs;
57876 -atomic_t fscache_n_allocs_intr;
57877 -atomic_t fscache_n_allocs_object_dead;
57878 -atomic_t fscache_n_alloc_ops;
57879 -atomic_t fscache_n_alloc_op_waits;
57880 +atomic_unchecked_t fscache_n_allocs;
57881 +atomic_unchecked_t fscache_n_allocs_ok;
57882 +atomic_unchecked_t fscache_n_allocs_wait;
57883 +atomic_unchecked_t fscache_n_allocs_nobufs;
57884 +atomic_unchecked_t fscache_n_allocs_intr;
57885 +atomic_unchecked_t fscache_n_allocs_object_dead;
57886 +atomic_unchecked_t fscache_n_alloc_ops;
57887 +atomic_unchecked_t fscache_n_alloc_op_waits;
57888
57889 -atomic_t fscache_n_retrievals;
57890 -atomic_t fscache_n_retrievals_ok;
57891 -atomic_t fscache_n_retrievals_wait;
57892 -atomic_t fscache_n_retrievals_nodata;
57893 -atomic_t fscache_n_retrievals_nobufs;
57894 -atomic_t fscache_n_retrievals_intr;
57895 -atomic_t fscache_n_retrievals_nomem;
57896 -atomic_t fscache_n_retrievals_object_dead;
57897 -atomic_t fscache_n_retrieval_ops;
57898 -atomic_t fscache_n_retrieval_op_waits;
57899 +atomic_unchecked_t fscache_n_retrievals;
57900 +atomic_unchecked_t fscache_n_retrievals_ok;
57901 +atomic_unchecked_t fscache_n_retrievals_wait;
57902 +atomic_unchecked_t fscache_n_retrievals_nodata;
57903 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57904 +atomic_unchecked_t fscache_n_retrievals_intr;
57905 +atomic_unchecked_t fscache_n_retrievals_nomem;
57906 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57907 +atomic_unchecked_t fscache_n_retrieval_ops;
57908 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57909
57910 -atomic_t fscache_n_stores;
57911 -atomic_t fscache_n_stores_ok;
57912 -atomic_t fscache_n_stores_again;
57913 -atomic_t fscache_n_stores_nobufs;
57914 -atomic_t fscache_n_stores_oom;
57915 -atomic_t fscache_n_store_ops;
57916 -atomic_t fscache_n_store_calls;
57917 -atomic_t fscache_n_store_pages;
57918 -atomic_t fscache_n_store_radix_deletes;
57919 -atomic_t fscache_n_store_pages_over_limit;
57920 +atomic_unchecked_t fscache_n_stores;
57921 +atomic_unchecked_t fscache_n_stores_ok;
57922 +atomic_unchecked_t fscache_n_stores_again;
57923 +atomic_unchecked_t fscache_n_stores_nobufs;
57924 +atomic_unchecked_t fscache_n_stores_oom;
57925 +atomic_unchecked_t fscache_n_store_ops;
57926 +atomic_unchecked_t fscache_n_store_calls;
57927 +atomic_unchecked_t fscache_n_store_pages;
57928 +atomic_unchecked_t fscache_n_store_radix_deletes;
57929 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57930
57931 -atomic_t fscache_n_store_vmscan_not_storing;
57932 -atomic_t fscache_n_store_vmscan_gone;
57933 -atomic_t fscache_n_store_vmscan_busy;
57934 -atomic_t fscache_n_store_vmscan_cancelled;
57935 -atomic_t fscache_n_store_vmscan_wait;
57936 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57937 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57938 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57939 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57940 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57941
57942 -atomic_t fscache_n_marks;
57943 -atomic_t fscache_n_uncaches;
57944 +atomic_unchecked_t fscache_n_marks;
57945 +atomic_unchecked_t fscache_n_uncaches;
57946
57947 -atomic_t fscache_n_acquires;
57948 -atomic_t fscache_n_acquires_null;
57949 -atomic_t fscache_n_acquires_no_cache;
57950 -atomic_t fscache_n_acquires_ok;
57951 -atomic_t fscache_n_acquires_nobufs;
57952 -atomic_t fscache_n_acquires_oom;
57953 +atomic_unchecked_t fscache_n_acquires;
57954 +atomic_unchecked_t fscache_n_acquires_null;
57955 +atomic_unchecked_t fscache_n_acquires_no_cache;
57956 +atomic_unchecked_t fscache_n_acquires_ok;
57957 +atomic_unchecked_t fscache_n_acquires_nobufs;
57958 +atomic_unchecked_t fscache_n_acquires_oom;
57959
57960 -atomic_t fscache_n_invalidates;
57961 -atomic_t fscache_n_invalidates_run;
57962 +atomic_unchecked_t fscache_n_invalidates;
57963 +atomic_unchecked_t fscache_n_invalidates_run;
57964
57965 -atomic_t fscache_n_updates;
57966 -atomic_t fscache_n_updates_null;
57967 -atomic_t fscache_n_updates_run;
57968 +atomic_unchecked_t fscache_n_updates;
57969 +atomic_unchecked_t fscache_n_updates_null;
57970 +atomic_unchecked_t fscache_n_updates_run;
57971
57972 -atomic_t fscache_n_relinquishes;
57973 -atomic_t fscache_n_relinquishes_null;
57974 -atomic_t fscache_n_relinquishes_waitcrt;
57975 -atomic_t fscache_n_relinquishes_retire;
57976 +atomic_unchecked_t fscache_n_relinquishes;
57977 +atomic_unchecked_t fscache_n_relinquishes_null;
57978 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57979 +atomic_unchecked_t fscache_n_relinquishes_retire;
57980
57981 -atomic_t fscache_n_cookie_index;
57982 -atomic_t fscache_n_cookie_data;
57983 -atomic_t fscache_n_cookie_special;
57984 +atomic_unchecked_t fscache_n_cookie_index;
57985 +atomic_unchecked_t fscache_n_cookie_data;
57986 +atomic_unchecked_t fscache_n_cookie_special;
57987
57988 -atomic_t fscache_n_object_alloc;
57989 -atomic_t fscache_n_object_no_alloc;
57990 -atomic_t fscache_n_object_lookups;
57991 -atomic_t fscache_n_object_lookups_negative;
57992 -atomic_t fscache_n_object_lookups_positive;
57993 -atomic_t fscache_n_object_lookups_timed_out;
57994 -atomic_t fscache_n_object_created;
57995 -atomic_t fscache_n_object_avail;
57996 -atomic_t fscache_n_object_dead;
57997 +atomic_unchecked_t fscache_n_object_alloc;
57998 +atomic_unchecked_t fscache_n_object_no_alloc;
57999 +atomic_unchecked_t fscache_n_object_lookups;
58000 +atomic_unchecked_t fscache_n_object_lookups_negative;
58001 +atomic_unchecked_t fscache_n_object_lookups_positive;
58002 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
58003 +atomic_unchecked_t fscache_n_object_created;
58004 +atomic_unchecked_t fscache_n_object_avail;
58005 +atomic_unchecked_t fscache_n_object_dead;
58006
58007 -atomic_t fscache_n_checkaux_none;
58008 -atomic_t fscache_n_checkaux_okay;
58009 -atomic_t fscache_n_checkaux_update;
58010 -atomic_t fscache_n_checkaux_obsolete;
58011 +atomic_unchecked_t fscache_n_checkaux_none;
58012 +atomic_unchecked_t fscache_n_checkaux_okay;
58013 +atomic_unchecked_t fscache_n_checkaux_update;
58014 +atomic_unchecked_t fscache_n_checkaux_obsolete;
58015
58016 atomic_t fscache_n_cop_alloc_object;
58017 atomic_t fscache_n_cop_lookup_object;
58018 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
58019 seq_puts(m, "FS-Cache statistics\n");
58020
58021 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
58022 - atomic_read(&fscache_n_cookie_index),
58023 - atomic_read(&fscache_n_cookie_data),
58024 - atomic_read(&fscache_n_cookie_special));
58025 + atomic_read_unchecked(&fscache_n_cookie_index),
58026 + atomic_read_unchecked(&fscache_n_cookie_data),
58027 + atomic_read_unchecked(&fscache_n_cookie_special));
58028
58029 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
58030 - atomic_read(&fscache_n_object_alloc),
58031 - atomic_read(&fscache_n_object_no_alloc),
58032 - atomic_read(&fscache_n_object_avail),
58033 - atomic_read(&fscache_n_object_dead));
58034 + atomic_read_unchecked(&fscache_n_object_alloc),
58035 + atomic_read_unchecked(&fscache_n_object_no_alloc),
58036 + atomic_read_unchecked(&fscache_n_object_avail),
58037 + atomic_read_unchecked(&fscache_n_object_dead));
58038 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
58039 - atomic_read(&fscache_n_checkaux_none),
58040 - atomic_read(&fscache_n_checkaux_okay),
58041 - atomic_read(&fscache_n_checkaux_update),
58042 - atomic_read(&fscache_n_checkaux_obsolete));
58043 + atomic_read_unchecked(&fscache_n_checkaux_none),
58044 + atomic_read_unchecked(&fscache_n_checkaux_okay),
58045 + atomic_read_unchecked(&fscache_n_checkaux_update),
58046 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
58047
58048 seq_printf(m, "Pages : mrk=%u unc=%u\n",
58049 - atomic_read(&fscache_n_marks),
58050 - atomic_read(&fscache_n_uncaches));
58051 + atomic_read_unchecked(&fscache_n_marks),
58052 + atomic_read_unchecked(&fscache_n_uncaches));
58053
58054 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
58055 " oom=%u\n",
58056 - atomic_read(&fscache_n_acquires),
58057 - atomic_read(&fscache_n_acquires_null),
58058 - atomic_read(&fscache_n_acquires_no_cache),
58059 - atomic_read(&fscache_n_acquires_ok),
58060 - atomic_read(&fscache_n_acquires_nobufs),
58061 - atomic_read(&fscache_n_acquires_oom));
58062 + atomic_read_unchecked(&fscache_n_acquires),
58063 + atomic_read_unchecked(&fscache_n_acquires_null),
58064 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
58065 + atomic_read_unchecked(&fscache_n_acquires_ok),
58066 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
58067 + atomic_read_unchecked(&fscache_n_acquires_oom));
58068
58069 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
58070 - atomic_read(&fscache_n_object_lookups),
58071 - atomic_read(&fscache_n_object_lookups_negative),
58072 - atomic_read(&fscache_n_object_lookups_positive),
58073 - atomic_read(&fscache_n_object_created),
58074 - atomic_read(&fscache_n_object_lookups_timed_out));
58075 + atomic_read_unchecked(&fscache_n_object_lookups),
58076 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
58077 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
58078 + atomic_read_unchecked(&fscache_n_object_created),
58079 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
58080
58081 seq_printf(m, "Invals : n=%u run=%u\n",
58082 - atomic_read(&fscache_n_invalidates),
58083 - atomic_read(&fscache_n_invalidates_run));
58084 + atomic_read_unchecked(&fscache_n_invalidates),
58085 + atomic_read_unchecked(&fscache_n_invalidates_run));
58086
58087 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
58088 - atomic_read(&fscache_n_updates),
58089 - atomic_read(&fscache_n_updates_null),
58090 - atomic_read(&fscache_n_updates_run));
58091 + atomic_read_unchecked(&fscache_n_updates),
58092 + atomic_read_unchecked(&fscache_n_updates_null),
58093 + atomic_read_unchecked(&fscache_n_updates_run));
58094
58095 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
58096 - atomic_read(&fscache_n_relinquishes),
58097 - atomic_read(&fscache_n_relinquishes_null),
58098 - atomic_read(&fscache_n_relinquishes_waitcrt),
58099 - atomic_read(&fscache_n_relinquishes_retire));
58100 + atomic_read_unchecked(&fscache_n_relinquishes),
58101 + atomic_read_unchecked(&fscache_n_relinquishes_null),
58102 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
58103 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
58104
58105 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
58106 - atomic_read(&fscache_n_attr_changed),
58107 - atomic_read(&fscache_n_attr_changed_ok),
58108 - atomic_read(&fscache_n_attr_changed_nobufs),
58109 - atomic_read(&fscache_n_attr_changed_nomem),
58110 - atomic_read(&fscache_n_attr_changed_calls));
58111 + atomic_read_unchecked(&fscache_n_attr_changed),
58112 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
58113 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
58114 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
58115 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
58116
58117 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
58118 - atomic_read(&fscache_n_allocs),
58119 - atomic_read(&fscache_n_allocs_ok),
58120 - atomic_read(&fscache_n_allocs_wait),
58121 - atomic_read(&fscache_n_allocs_nobufs),
58122 - atomic_read(&fscache_n_allocs_intr));
58123 + atomic_read_unchecked(&fscache_n_allocs),
58124 + atomic_read_unchecked(&fscache_n_allocs_ok),
58125 + atomic_read_unchecked(&fscache_n_allocs_wait),
58126 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
58127 + atomic_read_unchecked(&fscache_n_allocs_intr));
58128 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
58129 - atomic_read(&fscache_n_alloc_ops),
58130 - atomic_read(&fscache_n_alloc_op_waits),
58131 - atomic_read(&fscache_n_allocs_object_dead));
58132 + atomic_read_unchecked(&fscache_n_alloc_ops),
58133 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
58134 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
58135
58136 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
58137 " int=%u oom=%u\n",
58138 - atomic_read(&fscache_n_retrievals),
58139 - atomic_read(&fscache_n_retrievals_ok),
58140 - atomic_read(&fscache_n_retrievals_wait),
58141 - atomic_read(&fscache_n_retrievals_nodata),
58142 - atomic_read(&fscache_n_retrievals_nobufs),
58143 - atomic_read(&fscache_n_retrievals_intr),
58144 - atomic_read(&fscache_n_retrievals_nomem));
58145 + atomic_read_unchecked(&fscache_n_retrievals),
58146 + atomic_read_unchecked(&fscache_n_retrievals_ok),
58147 + atomic_read_unchecked(&fscache_n_retrievals_wait),
58148 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
58149 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
58150 + atomic_read_unchecked(&fscache_n_retrievals_intr),
58151 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
58152 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
58153 - atomic_read(&fscache_n_retrieval_ops),
58154 - atomic_read(&fscache_n_retrieval_op_waits),
58155 - atomic_read(&fscache_n_retrievals_object_dead));
58156 + atomic_read_unchecked(&fscache_n_retrieval_ops),
58157 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
58158 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
58159
58160 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
58161 - atomic_read(&fscache_n_stores),
58162 - atomic_read(&fscache_n_stores_ok),
58163 - atomic_read(&fscache_n_stores_again),
58164 - atomic_read(&fscache_n_stores_nobufs),
58165 - atomic_read(&fscache_n_stores_oom));
58166 + atomic_read_unchecked(&fscache_n_stores),
58167 + atomic_read_unchecked(&fscache_n_stores_ok),
58168 + atomic_read_unchecked(&fscache_n_stores_again),
58169 + atomic_read_unchecked(&fscache_n_stores_nobufs),
58170 + atomic_read_unchecked(&fscache_n_stores_oom));
58171 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
58172 - atomic_read(&fscache_n_store_ops),
58173 - atomic_read(&fscache_n_store_calls),
58174 - atomic_read(&fscache_n_store_pages),
58175 - atomic_read(&fscache_n_store_radix_deletes),
58176 - atomic_read(&fscache_n_store_pages_over_limit));
58177 + atomic_read_unchecked(&fscache_n_store_ops),
58178 + atomic_read_unchecked(&fscache_n_store_calls),
58179 + atomic_read_unchecked(&fscache_n_store_pages),
58180 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
58181 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
58182
58183 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
58184 - atomic_read(&fscache_n_store_vmscan_not_storing),
58185 - atomic_read(&fscache_n_store_vmscan_gone),
58186 - atomic_read(&fscache_n_store_vmscan_busy),
58187 - atomic_read(&fscache_n_store_vmscan_cancelled),
58188 - atomic_read(&fscache_n_store_vmscan_wait));
58189 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
58190 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
58191 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
58192 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
58193 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
58194
58195 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
58196 - atomic_read(&fscache_n_op_pend),
58197 - atomic_read(&fscache_n_op_run),
58198 - atomic_read(&fscache_n_op_enqueue),
58199 - atomic_read(&fscache_n_op_cancelled),
58200 - atomic_read(&fscache_n_op_rejected));
58201 + atomic_read_unchecked(&fscache_n_op_pend),
58202 + atomic_read_unchecked(&fscache_n_op_run),
58203 + atomic_read_unchecked(&fscache_n_op_enqueue),
58204 + atomic_read_unchecked(&fscache_n_op_cancelled),
58205 + atomic_read_unchecked(&fscache_n_op_rejected));
58206 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
58207 - atomic_read(&fscache_n_op_deferred_release),
58208 - atomic_read(&fscache_n_op_release),
58209 - atomic_read(&fscache_n_op_gc));
58210 + atomic_read_unchecked(&fscache_n_op_deferred_release),
58211 + atomic_read_unchecked(&fscache_n_op_release),
58212 + atomic_read_unchecked(&fscache_n_op_gc));
58213
58214 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
58215 atomic_read(&fscache_n_cop_alloc_object),
58216 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
58217 index aef34b1..59bfd7b 100644
58218 --- a/fs/fuse/cuse.c
58219 +++ b/fs/fuse/cuse.c
58220 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
58221 INIT_LIST_HEAD(&cuse_conntbl[i]);
58222
58223 /* inherit and extend fuse_dev_operations */
58224 - cuse_channel_fops = fuse_dev_operations;
58225 - cuse_channel_fops.owner = THIS_MODULE;
58226 - cuse_channel_fops.open = cuse_channel_open;
58227 - cuse_channel_fops.release = cuse_channel_release;
58228 + pax_open_kernel();
58229 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
58230 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
58231 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
58232 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
58233 + pax_close_kernel();
58234
58235 cuse_class = class_create(THIS_MODULE, "cuse");
58236 if (IS_ERR(cuse_class))
58237 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
58238 index 1d55f94..088da65 100644
58239 --- a/fs/fuse/dev.c
58240 +++ b/fs/fuse/dev.c
58241 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58242 ret = 0;
58243 pipe_lock(pipe);
58244
58245 - if (!pipe->readers) {
58246 + if (!atomic_read(&pipe->readers)) {
58247 send_sig(SIGPIPE, current, 0);
58248 if (!ret)
58249 ret = -EPIPE;
58250 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58251 page_nr++;
58252 ret += buf->len;
58253
58254 - if (pipe->files)
58255 + if (atomic_read(&pipe->files))
58256 do_wakeup = 1;
58257 }
58258
58259 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
58260 index 5b12746..b481b03 100644
58261 --- a/fs/fuse/dir.c
58262 +++ b/fs/fuse/dir.c
58263 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
58264 return link;
58265 }
58266
58267 -static void free_link(char *link)
58268 +static void free_link(const char *link)
58269 {
58270 if (!IS_ERR(link))
58271 free_page((unsigned long) link);
58272 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
58273 index 62b484e..0f9a140 100644
58274 --- a/fs/gfs2/inode.c
58275 +++ b/fs/gfs2/inode.c
58276 @@ -1441,7 +1441,7 @@ out:
58277
58278 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
58279 {
58280 - char *s = nd_get_link(nd);
58281 + const char *s = nd_get_link(nd);
58282 if (!IS_ERR(s))
58283 kfree(s);
58284 }
58285 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
58286 index a3f868a..bb308ae 100644
58287 --- a/fs/hugetlbfs/inode.c
58288 +++ b/fs/hugetlbfs/inode.c
58289 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58290 struct mm_struct *mm = current->mm;
58291 struct vm_area_struct *vma;
58292 struct hstate *h = hstate_file(file);
58293 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
58294 struct vm_unmapped_area_info info;
58295
58296 if (len & ~huge_page_mask(h))
58297 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58298 return addr;
58299 }
58300
58301 +#ifdef CONFIG_PAX_RANDMMAP
58302 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
58303 +#endif
58304 +
58305 if (addr) {
58306 addr = ALIGN(addr, huge_page_size(h));
58307 vma = find_vma(mm, addr);
58308 - if (TASK_SIZE - len >= addr &&
58309 - (!vma || addr + len <= vma->vm_start))
58310 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
58311 return addr;
58312 }
58313
58314 info.flags = 0;
58315 info.length = len;
58316 info.low_limit = TASK_UNMAPPED_BASE;
58317 +
58318 +#ifdef CONFIG_PAX_RANDMMAP
58319 + if (mm->pax_flags & MF_PAX_RANDMMAP)
58320 + info.low_limit += mm->delta_mmap;
58321 +#endif
58322 +
58323 info.high_limit = TASK_SIZE;
58324 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
58325 info.align_offset = 0;
58326 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
58327 };
58328 MODULE_ALIAS_FS("hugetlbfs");
58329
58330 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58331 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58332
58333 static int can_do_hugetlb_shm(void)
58334 {
58335 diff --git a/fs/inode.c b/fs/inode.c
58336 index 00d5fc3..98ce7d7 100644
58337 --- a/fs/inode.c
58338 +++ b/fs/inode.c
58339 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
58340
58341 #ifdef CONFIG_SMP
58342 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
58343 - static atomic_t shared_last_ino;
58344 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
58345 + static atomic_unchecked_t shared_last_ino;
58346 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
58347
58348 res = next - LAST_INO_BATCH;
58349 }
58350 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
58351 index 4a6cf28..d3a29d3 100644
58352 --- a/fs/jffs2/erase.c
58353 +++ b/fs/jffs2/erase.c
58354 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
58355 struct jffs2_unknown_node marker = {
58356 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
58357 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58358 - .totlen = cpu_to_je32(c->cleanmarker_size)
58359 + .totlen = cpu_to_je32(c->cleanmarker_size),
58360 + .hdr_crc = cpu_to_je32(0)
58361 };
58362
58363 jffs2_prealloc_raw_node_refs(c, jeb, 1);
58364 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
58365 index a6597d6..41b30ec 100644
58366 --- a/fs/jffs2/wbuf.c
58367 +++ b/fs/jffs2/wbuf.c
58368 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
58369 {
58370 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
58371 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58372 - .totlen = constant_cpu_to_je32(8)
58373 + .totlen = constant_cpu_to_je32(8),
58374 + .hdr_crc = constant_cpu_to_je32(0)
58375 };
58376
58377 /*
58378 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
58379 index 788e0a9..8433098 100644
58380 --- a/fs/jfs/super.c
58381 +++ b/fs/jfs/super.c
58382 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
58383
58384 jfs_inode_cachep =
58385 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
58386 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
58387 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
58388 init_once);
58389 if (jfs_inode_cachep == NULL)
58390 return -ENOMEM;
58391 diff --git a/fs/libfs.c b/fs/libfs.c
58392 index 916da8c..1588998 100644
58393 --- a/fs/libfs.c
58394 +++ b/fs/libfs.c
58395 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
58396
58397 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
58398 struct dentry *next;
58399 + char d_name[sizeof(next->d_iname)];
58400 + const unsigned char *name;
58401 +
58402 next = list_entry(p, struct dentry, d_u.d_child);
58403 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
58404 if (!simple_positive(next)) {
58405 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
58406
58407 spin_unlock(&next->d_lock);
58408 spin_unlock(&dentry->d_lock);
58409 - if (filldir(dirent, next->d_name.name,
58410 + name = next->d_name.name;
58411 + if (name == next->d_iname) {
58412 + memcpy(d_name, name, next->d_name.len);
58413 + name = d_name;
58414 + }
58415 + if (filldir(dirent, name,
58416 next->d_name.len, filp->f_pos,
58417 next->d_inode->i_ino,
58418 dt_type(next->d_inode)) < 0)
58419 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58420 index acd3947..1f896e2 100644
58421 --- a/fs/lockd/clntproc.c
58422 +++ b/fs/lockd/clntproc.c
58423 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58424 /*
58425 * Cookie counter for NLM requests
58426 */
58427 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58428 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58429
58430 void nlmclnt_next_cookie(struct nlm_cookie *c)
58431 {
58432 - u32 cookie = atomic_inc_return(&nlm_cookie);
58433 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58434
58435 memcpy(c->data, &cookie, 4);
58436 c->len=4;
58437 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
58438 index a2aa97d..10d6c41 100644
58439 --- a/fs/lockd/svc.c
58440 +++ b/fs/lockd/svc.c
58441 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
58442 svc_sock_update_bufs(serv);
58443 serv->sv_maxconn = nlm_max_connections;
58444
58445 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
58446 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
58447 if (IS_ERR(nlmsvc_task)) {
58448 error = PTR_ERR(nlmsvc_task);
58449 printk(KERN_WARNING
58450 diff --git a/fs/locks.c b/fs/locks.c
58451 index cb424a4..850e4dd 100644
58452 --- a/fs/locks.c
58453 +++ b/fs/locks.c
58454 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
58455 return;
58456
58457 if (filp->f_op && filp->f_op->flock) {
58458 - struct file_lock fl = {
58459 + struct file_lock flock = {
58460 .fl_pid = current->tgid,
58461 .fl_file = filp,
58462 .fl_flags = FL_FLOCK,
58463 .fl_type = F_UNLCK,
58464 .fl_end = OFFSET_MAX,
58465 };
58466 - filp->f_op->flock(filp, F_SETLKW, &fl);
58467 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58468 - fl.fl_ops->fl_release_private(&fl);
58469 + filp->f_op->flock(filp, F_SETLKW, &flock);
58470 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58471 + flock.fl_ops->fl_release_private(&flock);
58472 }
58473
58474 lock_flocks();
58475 diff --git a/fs/namei.c b/fs/namei.c
58476 index 9ed9361..2b72db1 100644
58477 --- a/fs/namei.c
58478 +++ b/fs/namei.c
58479 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58480 if (ret != -EACCES)
58481 return ret;
58482
58483 +#ifdef CONFIG_GRKERNSEC
58484 + /* we'll block if we have to log due to a denied capability use */
58485 + if (mask & MAY_NOT_BLOCK)
58486 + return -ECHILD;
58487 +#endif
58488 +
58489 if (S_ISDIR(inode->i_mode)) {
58490 /* DACs are overridable for directories */
58491 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58492 - return 0;
58493 if (!(mask & MAY_WRITE))
58494 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58495 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58496 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58497 return 0;
58498 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58499 + return 0;
58500 return -EACCES;
58501 }
58502 /*
58503 + * Searching includes executable on directories, else just read.
58504 + */
58505 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58506 + if (mask == MAY_READ)
58507 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58508 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58509 + return 0;
58510 +
58511 + /*
58512 * Read/write DACs are always overridable.
58513 * Executable DACs are overridable when there is
58514 * at least one exec bit set.
58515 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58516 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58517 return 0;
58518
58519 - /*
58520 - * Searching includes executable on directories, else just read.
58521 - */
58522 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58523 - if (mask == MAY_READ)
58524 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58525 - return 0;
58526 -
58527 return -EACCES;
58528 }
58529
58530 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58531 {
58532 struct dentry *dentry = link->dentry;
58533 int error;
58534 - char *s;
58535 + const char *s;
58536
58537 BUG_ON(nd->flags & LOOKUP_RCU);
58538
58539 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58540 if (error)
58541 goto out_put_nd_path;
58542
58543 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58544 + dentry->d_inode, dentry, nd->path.mnt)) {
58545 + error = -EACCES;
58546 + goto out_put_nd_path;
58547 + }
58548 +
58549 nd->last_type = LAST_BIND;
58550 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58551 error = PTR_ERR(*p);
58552 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58553 if (res)
58554 break;
58555 res = walk_component(nd, path, LOOKUP_FOLLOW);
58556 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58557 + res = -EACCES;
58558 put_link(nd, &link, cookie);
58559 } while (res > 0);
58560
58561 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
58562 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58563 {
58564 unsigned long a, b, adata, bdata, mask, hash, len;
58565 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58566 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58567
58568 hash = a = 0;
58569 len = -sizeof(unsigned long);
58570 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
58571 if (err)
58572 break;
58573 err = lookup_last(nd, &path);
58574 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58575 + err = -EACCES;
58576 put_link(nd, &link, cookie);
58577 }
58578 }
58579 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
58580 if (!err)
58581 err = complete_walk(nd);
58582
58583 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58584 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58585 + path_put(&nd->path);
58586 + err = -ENOENT;
58587 + }
58588 + }
58589 +
58590 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58591 if (!can_lookup(nd->inode)) {
58592 path_put(&nd->path);
58593 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
58594 retval = path_lookupat(dfd, name->name,
58595 flags | LOOKUP_REVAL, nd);
58596
58597 - if (likely(!retval))
58598 + if (likely(!retval)) {
58599 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58600 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58601 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58602 + path_put(&nd->path);
58603 + return -ENOENT;
58604 + }
58605 + }
58606 + }
58607 return retval;
58608 }
58609
58610 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58611 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58612 return -EPERM;
58613
58614 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58615 + return -EPERM;
58616 + if (gr_handle_rawio(inode))
58617 + return -EPERM;
58618 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58619 + return -EACCES;
58620 +
58621 return 0;
58622 }
58623
58624 @@ -2602,7 +2641,7 @@ looked_up:
58625 * cleared otherwise prior to returning.
58626 */
58627 static int lookup_open(struct nameidata *nd, struct path *path,
58628 - struct file *file,
58629 + struct path *link, struct file *file,
58630 const struct open_flags *op,
58631 bool got_write, int *opened)
58632 {
58633 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58634 /* Negative dentry, just create the file */
58635 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58636 umode_t mode = op->mode;
58637 +
58638 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58639 + error = -EACCES;
58640 + goto out_dput;
58641 + }
58642 +
58643 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58644 + error = -EACCES;
58645 + goto out_dput;
58646 + }
58647 +
58648 if (!IS_POSIXACL(dir->d_inode))
58649 mode &= ~current_umask();
58650 /*
58651 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58652 nd->flags & LOOKUP_EXCL);
58653 if (error)
58654 goto out_dput;
58655 + else
58656 + gr_handle_create(dentry, nd->path.mnt);
58657 }
58658 out_no_open:
58659 path->dentry = dentry;
58660 @@ -2672,7 +2724,7 @@ out_dput:
58661 /*
58662 * Handle the last step of open()
58663 */
58664 -static int do_last(struct nameidata *nd, struct path *path,
58665 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58666 struct file *file, const struct open_flags *op,
58667 int *opened, struct filename *name)
58668 {
58669 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
58670 error = complete_walk(nd);
58671 if (error)
58672 return error;
58673 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58674 + error = -ENOENT;
58675 + goto out;
58676 + }
58677 audit_inode(name, nd->path.dentry, 0);
58678 if (open_flag & O_CREAT) {
58679 error = -EISDIR;
58680 goto out;
58681 }
58682 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58683 + error = -EACCES;
58684 + goto out;
58685 + }
58686 goto finish_open;
58687 case LAST_BIND:
58688 error = complete_walk(nd);
58689 if (error)
58690 return error;
58691 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58692 + error = -ENOENT;
58693 + goto out;
58694 + }
58695 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58696 + error = -EACCES;
58697 + goto out;
58698 + }
58699 audit_inode(name, dir, 0);
58700 goto finish_open;
58701 }
58702 @@ -2759,7 +2827,7 @@ retry_lookup:
58703 */
58704 }
58705 mutex_lock(&dir->d_inode->i_mutex);
58706 - error = lookup_open(nd, path, file, op, got_write, opened);
58707 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58708 mutex_unlock(&dir->d_inode->i_mutex);
58709
58710 if (error <= 0) {
58711 @@ -2783,11 +2851,28 @@ retry_lookup:
58712 goto finish_open_created;
58713 }
58714
58715 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58716 + error = -ENOENT;
58717 + goto exit_dput;
58718 + }
58719 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58720 + error = -EACCES;
58721 + goto exit_dput;
58722 + }
58723 +
58724 /*
58725 * create/update audit record if it already exists.
58726 */
58727 - if (path->dentry->d_inode)
58728 + if (path->dentry->d_inode) {
58729 + /* only check if O_CREAT is specified, all other checks need to go
58730 + into may_open */
58731 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58732 + error = -EACCES;
58733 + goto exit_dput;
58734 + }
58735 +
58736 audit_inode(name, path->dentry, 0);
58737 + }
58738
58739 /*
58740 * If atomic_open() acquired write access it is dropped now due to
58741 @@ -2828,6 +2913,11 @@ finish_lookup:
58742 }
58743 }
58744 BUG_ON(inode != path->dentry->d_inode);
58745 + /* if we're resolving a symlink to another symlink */
58746 + if (link && gr_handle_symlink_owner(link, inode)) {
58747 + error = -EACCES;
58748 + goto out;
58749 + }
58750 return 1;
58751 }
58752
58753 @@ -2837,7 +2927,6 @@ finish_lookup:
58754 save_parent.dentry = nd->path.dentry;
58755 save_parent.mnt = mntget(path->mnt);
58756 nd->path.dentry = path->dentry;
58757 -
58758 }
58759 nd->inode = inode;
58760 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58761 @@ -2846,6 +2935,16 @@ finish_lookup:
58762 path_put(&save_parent);
58763 return error;
58764 }
58765 +
58766 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58767 + error = -ENOENT;
58768 + goto out;
58769 + }
58770 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58771 + error = -EACCES;
58772 + goto out;
58773 + }
58774 +
58775 error = -EISDIR;
58776 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58777 goto out;
58778 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58779 if (unlikely(error))
58780 goto out;
58781
58782 - error = do_last(nd, &path, file, op, &opened, pathname);
58783 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58784 while (unlikely(error > 0)) { /* trailing symlink */
58785 struct path link = path;
58786 void *cookie;
58787 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58788 error = follow_link(&link, nd, &cookie);
58789 if (unlikely(error))
58790 break;
58791 - error = do_last(nd, &path, file, op, &opened, pathname);
58792 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58793 put_link(nd, &link, cookie);
58794 }
58795 out:
58796 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58797 goto unlock;
58798
58799 error = -EEXIST;
58800 - if (dentry->d_inode)
58801 + if (dentry->d_inode) {
58802 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58803 + error = -ENOENT;
58804 + }
58805 goto fail;
58806 + }
58807 /*
58808 * Special case - lookup gave negative, but... we had foo/bar/
58809 * From the vfs_mknod() POV we just have a negative dentry -
58810 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58811 }
58812 EXPORT_SYMBOL(user_path_create);
58813
58814 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58815 +{
58816 + struct filename *tmp = getname(pathname);
58817 + struct dentry *res;
58818 + if (IS_ERR(tmp))
58819 + return ERR_CAST(tmp);
58820 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58821 + if (IS_ERR(res))
58822 + putname(tmp);
58823 + else
58824 + *to = tmp;
58825 + return res;
58826 +}
58827 +
58828 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58829 {
58830 int error = may_create(dir, dentry);
58831 @@ -3177,6 +3294,17 @@ retry:
58832
58833 if (!IS_POSIXACL(path.dentry->d_inode))
58834 mode &= ~current_umask();
58835 +
58836 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58837 + error = -EPERM;
58838 + goto out;
58839 + }
58840 +
58841 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58842 + error = -EACCES;
58843 + goto out;
58844 + }
58845 +
58846 error = security_path_mknod(&path, dentry, mode, dev);
58847 if (error)
58848 goto out;
58849 @@ -3193,6 +3321,8 @@ retry:
58850 break;
58851 }
58852 out:
58853 + if (!error)
58854 + gr_handle_create(dentry, path.mnt);
58855 done_path_create(&path, dentry);
58856 if (retry_estale(error, lookup_flags)) {
58857 lookup_flags |= LOOKUP_REVAL;
58858 @@ -3245,9 +3375,16 @@ retry:
58859
58860 if (!IS_POSIXACL(path.dentry->d_inode))
58861 mode &= ~current_umask();
58862 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58863 + error = -EACCES;
58864 + goto out;
58865 + }
58866 error = security_path_mkdir(&path, dentry, mode);
58867 if (!error)
58868 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58869 + if (!error)
58870 + gr_handle_create(dentry, path.mnt);
58871 +out:
58872 done_path_create(&path, dentry);
58873 if (retry_estale(error, lookup_flags)) {
58874 lookup_flags |= LOOKUP_REVAL;
58875 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
58876 struct filename *name;
58877 struct dentry *dentry;
58878 struct nameidata nd;
58879 + ino_t saved_ino = 0;
58880 + dev_t saved_dev = 0;
58881 unsigned int lookup_flags = 0;
58882 retry:
58883 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58884 @@ -3360,10 +3499,21 @@ retry:
58885 error = -ENOENT;
58886 goto exit3;
58887 }
58888 +
58889 + saved_ino = dentry->d_inode->i_ino;
58890 + saved_dev = gr_get_dev_from_dentry(dentry);
58891 +
58892 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
58893 + error = -EACCES;
58894 + goto exit3;
58895 + }
58896 +
58897 error = security_path_rmdir(&nd.path, dentry);
58898 if (error)
58899 goto exit3;
58900 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
58901 + if (!error && (saved_dev || saved_ino))
58902 + gr_handle_delete(saved_ino, saved_dev);
58903 exit3:
58904 dput(dentry);
58905 exit2:
58906 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58907 struct dentry *dentry;
58908 struct nameidata nd;
58909 struct inode *inode = NULL;
58910 + ino_t saved_ino = 0;
58911 + dev_t saved_dev = 0;
58912 unsigned int lookup_flags = 0;
58913 retry:
58914 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58915 @@ -3455,10 +3607,22 @@ retry:
58916 if (!inode)
58917 goto slashes;
58918 ihold(inode);
58919 +
58920 + if (inode->i_nlink <= 1) {
58921 + saved_ino = inode->i_ino;
58922 + saved_dev = gr_get_dev_from_dentry(dentry);
58923 + }
58924 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58925 + error = -EACCES;
58926 + goto exit2;
58927 + }
58928 +
58929 error = security_path_unlink(&nd.path, dentry);
58930 if (error)
58931 goto exit2;
58932 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58933 + if (!error && (saved_ino || saved_dev))
58934 + gr_handle_delete(saved_ino, saved_dev);
58935 exit2:
58936 dput(dentry);
58937 }
58938 @@ -3536,9 +3700,17 @@ retry:
58939 if (IS_ERR(dentry))
58940 goto out_putname;
58941
58942 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58943 + error = -EACCES;
58944 + goto out;
58945 + }
58946 +
58947 error = security_path_symlink(&path, dentry, from->name);
58948 if (!error)
58949 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58950 + if (!error)
58951 + gr_handle_create(dentry, path.mnt);
58952 +out:
58953 done_path_create(&path, dentry);
58954 if (retry_estale(error, lookup_flags)) {
58955 lookup_flags |= LOOKUP_REVAL;
58956 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58957 {
58958 struct dentry *new_dentry;
58959 struct path old_path, new_path;
58960 + struct filename *to = NULL;
58961 int how = 0;
58962 int error;
58963
58964 @@ -3635,7 +3808,7 @@ retry:
58965 if (error)
58966 return error;
58967
58968 - new_dentry = user_path_create(newdfd, newname, &new_path,
58969 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58970 (how & LOOKUP_REVAL));
58971 error = PTR_ERR(new_dentry);
58972 if (IS_ERR(new_dentry))
58973 @@ -3647,11 +3820,28 @@ retry:
58974 error = may_linkat(&old_path);
58975 if (unlikely(error))
58976 goto out_dput;
58977 +
58978 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58979 + old_path.dentry->d_inode,
58980 + old_path.dentry->d_inode->i_mode, to)) {
58981 + error = -EACCES;
58982 + goto out_dput;
58983 + }
58984 +
58985 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58986 + old_path.dentry, old_path.mnt, to)) {
58987 + error = -EACCES;
58988 + goto out_dput;
58989 + }
58990 +
58991 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58992 if (error)
58993 goto out_dput;
58994 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58995 + if (!error)
58996 + gr_handle_create(new_dentry, new_path.mnt);
58997 out_dput:
58998 + putname(to);
58999 done_path_create(&new_path, new_dentry);
59000 if (retry_estale(error, how)) {
59001 how |= LOOKUP_REVAL;
59002 @@ -3897,12 +4087,21 @@ retry:
59003 if (new_dentry == trap)
59004 goto exit5;
59005
59006 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
59007 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
59008 + to);
59009 + if (error)
59010 + goto exit5;
59011 +
59012 error = security_path_rename(&oldnd.path, old_dentry,
59013 &newnd.path, new_dentry);
59014 if (error)
59015 goto exit5;
59016 error = vfs_rename(old_dir->d_inode, old_dentry,
59017 new_dir->d_inode, new_dentry);
59018 + if (!error)
59019 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
59020 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
59021 exit5:
59022 dput(new_dentry);
59023 exit4:
59024 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
59025
59026 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
59027 {
59028 + char tmpbuf[64];
59029 + const char *newlink;
59030 int len;
59031
59032 len = PTR_ERR(link);
59033 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
59034 len = strlen(link);
59035 if (len > (unsigned) buflen)
59036 len = buflen;
59037 - if (copy_to_user(buffer, link, len))
59038 +
59039 + if (len < sizeof(tmpbuf)) {
59040 + memcpy(tmpbuf, link, len);
59041 + newlink = tmpbuf;
59042 + } else
59043 + newlink = link;
59044 +
59045 + if (copy_to_user(buffer, newlink, len))
59046 len = -EFAULT;
59047 out:
59048 return len;
59049 diff --git a/fs/namespace.c b/fs/namespace.c
59050 index a45ba4f..44cfe66 100644
59051 --- a/fs/namespace.c
59052 +++ b/fs/namespace.c
59053 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
59054 if (!(sb->s_flags & MS_RDONLY))
59055 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
59056 up_write(&sb->s_umount);
59057 +
59058 + gr_log_remount(mnt->mnt_devname, retval);
59059 +
59060 return retval;
59061 }
59062
59063 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
59064 }
59065 br_write_unlock(&vfsmount_lock);
59066 namespace_unlock();
59067 +
59068 + gr_log_unmount(mnt->mnt_devname, retval);
59069 +
59070 return retval;
59071 }
59072
59073 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
59074 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
59075 */
59076
59077 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
59078 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
59079 {
59080 struct path path;
59081 struct mount *mnt;
59082 @@ -1342,7 +1348,7 @@ out:
59083 /*
59084 * The 2.0 compatible umount. No flags.
59085 */
59086 -SYSCALL_DEFINE1(oldumount, char __user *, name)
59087 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
59088 {
59089 return sys_umount(name, 0);
59090 }
59091 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
59092 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
59093 MS_STRICTATIME);
59094
59095 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
59096 + retval = -EPERM;
59097 + goto dput_out;
59098 + }
59099 +
59100 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
59101 + retval = -EPERM;
59102 + goto dput_out;
59103 + }
59104 +
59105 if (flags & MS_REMOUNT)
59106 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
59107 data_page);
59108 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
59109 dev_name, data_page);
59110 dput_out:
59111 path_put(&path);
59112 +
59113 + gr_log_mount(dev_name, dir_name, retval);
59114 +
59115 return retval;
59116 }
59117
59118 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
59119 * number incrementing at 10Ghz will take 12,427 years to wrap which
59120 * is effectively never, so we can ignore the possibility.
59121 */
59122 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
59123 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
59124
59125 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59126 {
59127 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59128 kfree(new_ns);
59129 return ERR_PTR(ret);
59130 }
59131 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
59132 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
59133 atomic_set(&new_ns->count, 1);
59134 new_ns->root = NULL;
59135 INIT_LIST_HEAD(&new_ns->list);
59136 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
59137 }
59138 EXPORT_SYMBOL(mount_subtree);
59139
59140 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
59141 - char __user *, type, unsigned long, flags, void __user *, data)
59142 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
59143 + const char __user *, type, unsigned long, flags, void __user *, data)
59144 {
59145 int ret;
59146 char *kernel_type;
59147 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
59148 if (error)
59149 goto out2;
59150
59151 + if (gr_handle_chroot_pivot()) {
59152 + error = -EPERM;
59153 + goto out2;
59154 + }
59155 +
59156 get_fs_root(current->fs, &root);
59157 old_mp = lock_mount(&old);
59158 error = PTR_ERR(old_mp);
59159 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
59160 !nsown_capable(CAP_SYS_ADMIN))
59161 return -EPERM;
59162
59163 - if (fs->users != 1)
59164 + if (atomic_read(&fs->users) != 1)
59165 return -EINVAL;
59166
59167 get_mnt_ns(mnt_ns);
59168 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
59169 index cff089a..4c3d57a 100644
59170 --- a/fs/nfs/callback.c
59171 +++ b/fs/nfs/callback.c
59172 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
59173 struct svc_rqst *rqstp;
59174 int (*callback_svc)(void *vrqstp);
59175 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
59176 - char svc_name[12];
59177 int ret;
59178
59179 nfs_callback_bc_serv(minorversion, xprt, serv);
59180 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
59181
59182 svc_sock_update_bufs(serv);
59183
59184 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
59185 cb_info->serv = serv;
59186 cb_info->rqst = rqstp;
59187 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
59188 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
59189 if (IS_ERR(cb_info->task)) {
59190 ret = PTR_ERR(cb_info->task);
59191 svc_exit_thread(cb_info->rqst);
59192 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
59193 index a35582c..ebbdcd5 100644
59194 --- a/fs/nfs/callback_xdr.c
59195 +++ b/fs/nfs/callback_xdr.c
59196 @@ -51,7 +51,7 @@ struct callback_op {
59197 callback_decode_arg_t decode_args;
59198 callback_encode_res_t encode_res;
59199 long res_maxsize;
59200 -};
59201 +} __do_const;
59202
59203 static struct callback_op callback_ops[];
59204
59205 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
59206 index c1c7a9d..7afa0b8 100644
59207 --- a/fs/nfs/inode.c
59208 +++ b/fs/nfs/inode.c
59209 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
59210 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
59211 }
59212
59213 -static atomic_long_t nfs_attr_generation_counter;
59214 +static atomic_long_unchecked_t nfs_attr_generation_counter;
59215
59216 static unsigned long nfs_read_attr_generation_counter(void)
59217 {
59218 - return atomic_long_read(&nfs_attr_generation_counter);
59219 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
59220 }
59221
59222 unsigned long nfs_inc_attr_generation_counter(void)
59223 {
59224 - return atomic_long_inc_return(&nfs_attr_generation_counter);
59225 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
59226 }
59227
59228 void nfs_fattr_init(struct nfs_fattr *fattr)
59229 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
59230 index 2c37442..9b9538b 100644
59231 --- a/fs/nfs/nfs4state.c
59232 +++ b/fs/nfs/nfs4state.c
59233 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
59234 snprintf(buf, sizeof(buf), "%s-manager",
59235 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
59236 rcu_read_unlock();
59237 - task = kthread_run(nfs4_run_state_manager, clp, buf);
59238 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
59239 if (IS_ERR(task)) {
59240 printk(KERN_ERR "%s: kthread_run: %ld\n",
59241 __func__, PTR_ERR(task));
59242 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
59243 index 27d74a2..c4c2a73 100644
59244 --- a/fs/nfsd/nfs4proc.c
59245 +++ b/fs/nfsd/nfs4proc.c
59246 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
59247 nfsd4op_rsize op_rsize_bop;
59248 stateid_getter op_get_currentstateid;
59249 stateid_setter op_set_currentstateid;
59250 -};
59251 +} __do_const;
59252
59253 static struct nfsd4_operation nfsd4_ops[];
59254
59255 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
59256 index 582321a..0224663 100644
59257 --- a/fs/nfsd/nfs4xdr.c
59258 +++ b/fs/nfsd/nfs4xdr.c
59259 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
59260
59261 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
59262
59263 -static nfsd4_dec nfsd4_dec_ops[] = {
59264 +static const nfsd4_dec nfsd4_dec_ops[] = {
59265 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59266 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59267 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59268 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
59269 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
59270 };
59271
59272 -static nfsd4_dec nfsd41_dec_ops[] = {
59273 +static const nfsd4_dec nfsd41_dec_ops[] = {
59274 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59275 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59276 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59277 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
59278 };
59279
59280 struct nfsd4_minorversion_ops {
59281 - nfsd4_dec *decoders;
59282 + const nfsd4_dec *decoders;
59283 int nops;
59284 };
59285
59286 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
59287 index e76244e..9fe8f2f1 100644
59288 --- a/fs/nfsd/nfscache.c
59289 +++ b/fs/nfsd/nfscache.c
59290 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
59291 {
59292 struct svc_cacherep *rp = rqstp->rq_cacherep;
59293 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
59294 - int len;
59295 + long len;
59296 size_t bufsize = 0;
59297
59298 if (!rp)
59299 return;
59300
59301 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
59302 - len >>= 2;
59303 + if (statp) {
59304 + len = (char*)statp - (char*)resv->iov_base;
59305 + len = resv->iov_len - len;
59306 + len >>= 2;
59307 + }
59308
59309 /* Don't cache excessive amounts of data and XDR failures */
59310 if (!statp || len > (256 >> 2)) {
59311 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
59312 index baf149a..76b86ad 100644
59313 --- a/fs/nfsd/vfs.c
59314 +++ b/fs/nfsd/vfs.c
59315 @@ -940,7 +940,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59316 } else {
59317 oldfs = get_fs();
59318 set_fs(KERNEL_DS);
59319 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
59320 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
59321 set_fs(oldfs);
59322 }
59323
59324 @@ -1027,7 +1027,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59325
59326 /* Write the data. */
59327 oldfs = get_fs(); set_fs(KERNEL_DS);
59328 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
59329 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
59330 set_fs(oldfs);
59331 if (host_err < 0)
59332 goto out_nfserr;
59333 @@ -1573,7 +1573,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
59334 */
59335
59336 oldfs = get_fs(); set_fs(KERNEL_DS);
59337 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
59338 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
59339 set_fs(oldfs);
59340
59341 if (host_err < 0)
59342 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
59343 index fea6bd5..8ee9d81 100644
59344 --- a/fs/nls/nls_base.c
59345 +++ b/fs/nls/nls_base.c
59346 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
59347
59348 int register_nls(struct nls_table * nls)
59349 {
59350 - struct nls_table ** tmp = &tables;
59351 + struct nls_table *tmp = tables;
59352
59353 if (nls->next)
59354 return -EBUSY;
59355
59356 spin_lock(&nls_lock);
59357 - while (*tmp) {
59358 - if (nls == *tmp) {
59359 + while (tmp) {
59360 + if (nls == tmp) {
59361 spin_unlock(&nls_lock);
59362 return -EBUSY;
59363 }
59364 - tmp = &(*tmp)->next;
59365 + tmp = tmp->next;
59366 }
59367 - nls->next = tables;
59368 + pax_open_kernel();
59369 + *(struct nls_table **)&nls->next = tables;
59370 + pax_close_kernel();
59371 tables = nls;
59372 spin_unlock(&nls_lock);
59373 return 0;
59374 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
59375
59376 int unregister_nls(struct nls_table * nls)
59377 {
59378 - struct nls_table ** tmp = &tables;
59379 + struct nls_table * const * tmp = &tables;
59380
59381 spin_lock(&nls_lock);
59382 while (*tmp) {
59383 if (nls == *tmp) {
59384 - *tmp = nls->next;
59385 + pax_open_kernel();
59386 + *(struct nls_table **)tmp = nls->next;
59387 + pax_close_kernel();
59388 spin_unlock(&nls_lock);
59389 return 0;
59390 }
59391 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
59392 index 7424929..35f6be5 100644
59393 --- a/fs/nls/nls_euc-jp.c
59394 +++ b/fs/nls/nls_euc-jp.c
59395 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
59396 p_nls = load_nls("cp932");
59397
59398 if (p_nls) {
59399 - table.charset2upper = p_nls->charset2upper;
59400 - table.charset2lower = p_nls->charset2lower;
59401 + pax_open_kernel();
59402 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59403 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59404 + pax_close_kernel();
59405 return register_nls(&table);
59406 }
59407
59408 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
59409 index e7bc1d7..06bd4bb 100644
59410 --- a/fs/nls/nls_koi8-ru.c
59411 +++ b/fs/nls/nls_koi8-ru.c
59412 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
59413 p_nls = load_nls("koi8-u");
59414
59415 if (p_nls) {
59416 - table.charset2upper = p_nls->charset2upper;
59417 - table.charset2lower = p_nls->charset2lower;
59418 + pax_open_kernel();
59419 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59420 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59421 + pax_close_kernel();
59422 return register_nls(&table);
59423 }
59424
59425 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
59426 index 77cc85d..a1e6299 100644
59427 --- a/fs/notify/fanotify/fanotify_user.c
59428 +++ b/fs/notify/fanotify/fanotify_user.c
59429 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
59430
59431 fd = fanotify_event_metadata.fd;
59432 ret = -EFAULT;
59433 - if (copy_to_user(buf, &fanotify_event_metadata,
59434 - fanotify_event_metadata.event_len))
59435 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
59436 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
59437 goto out_close_fd;
59438
59439 ret = prepare_for_access_response(group, event, fd);
59440 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
59441 index 7b51b05..5ea5ef6 100644
59442 --- a/fs/notify/notification.c
59443 +++ b/fs/notify/notification.c
59444 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
59445 * get set to 0 so it will never get 'freed'
59446 */
59447 static struct fsnotify_event *q_overflow_event;
59448 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59449 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59450
59451 /**
59452 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
59453 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59454 */
59455 u32 fsnotify_get_cookie(void)
59456 {
59457 - return atomic_inc_return(&fsnotify_sync_cookie);
59458 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
59459 }
59460 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
59461
59462 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
59463 index aa411c3..c260a84 100644
59464 --- a/fs/ntfs/dir.c
59465 +++ b/fs/ntfs/dir.c
59466 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
59467 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
59468 ~(s64)(ndir->itype.index.block_size - 1)));
59469 /* Bounds checks. */
59470 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59471 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59472 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59473 "inode 0x%lx or driver bug.", vdir->i_ino);
59474 goto err_out;
59475 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59476 index c5670b8..2b43d9b 100644
59477 --- a/fs/ntfs/file.c
59478 +++ b/fs/ntfs/file.c
59479 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59480 char *addr;
59481 size_t total = 0;
59482 unsigned len;
59483 - int left;
59484 + unsigned left;
59485
59486 do {
59487 len = PAGE_CACHE_SIZE - ofs;
59488 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
59489 #endif /* NTFS_RW */
59490 };
59491
59492 -const struct file_operations ntfs_empty_file_ops = {};
59493 +const struct file_operations ntfs_empty_file_ops __read_only;
59494
59495 -const struct inode_operations ntfs_empty_inode_ops = {};
59496 +const struct inode_operations ntfs_empty_inode_ops __read_only;
59497 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59498 index 82650d5..db37dcf 100644
59499 --- a/fs/ntfs/super.c
59500 +++ b/fs/ntfs/super.c
59501 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59502 if (!silent)
59503 ntfs_error(sb, "Primary boot sector is invalid.");
59504 } else if (!silent)
59505 - ntfs_error(sb, read_err_str, "primary");
59506 + ntfs_error(sb, read_err_str, "%s", "primary");
59507 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59508 if (bh_primary)
59509 brelse(bh_primary);
59510 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59511 goto hotfix_primary_boot_sector;
59512 brelse(bh_backup);
59513 } else if (!silent)
59514 - ntfs_error(sb, read_err_str, "backup");
59515 + ntfs_error(sb, read_err_str, "%s", "backup");
59516 /* Try to read NT3.51- backup boot sector. */
59517 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59518 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59519 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59520 "sector.");
59521 brelse(bh_backup);
59522 } else if (!silent)
59523 - ntfs_error(sb, read_err_str, "backup");
59524 + ntfs_error(sb, read_err_str, "%s", "backup");
59525 /* We failed. Cleanup and return. */
59526 if (bh_primary)
59527 brelse(bh_primary);
59528 diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
59529 index 20dfec7..e238cb7 100644
59530 --- a/fs/ocfs2/aops.c
59531 +++ b/fs/ocfs2/aops.c
59532 @@ -1756,7 +1756,7 @@ try_again:
59533 goto out;
59534 } else if (ret == 1) {
59535 clusters_need = wc->w_clen;
59536 - ret = ocfs2_refcount_cow(inode, filp, di_bh,
59537 + ret = ocfs2_refcount_cow(inode, di_bh,
59538 wc->w_cpos, wc->w_clen, UINT_MAX);
59539 if (ret) {
59540 mlog_errno(ret);
59541 diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
59542 index ff54014..ff125fd 100644
59543 --- a/fs/ocfs2/file.c
59544 +++ b/fs/ocfs2/file.c
59545 @@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
59546 if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
59547 goto out;
59548
59549 - return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
59550 + return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
59551
59552 out:
59553 return status;
59554 @@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
59555 zero_clusters = last_cpos - zero_cpos;
59556
59557 if (needs_cow) {
59558 - rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
59559 + rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
59560 zero_clusters, UINT_MAX);
59561 if (rc) {
59562 mlog_errno(rc);
59563 @@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
59564
59565 *meta_level = 1;
59566
59567 - ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
59568 + ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
59569 if (ret)
59570 mlog_errno(ret);
59571 out:
59572 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59573 index aebeacd..0dcdd26 100644
59574 --- a/fs/ocfs2/localalloc.c
59575 +++ b/fs/ocfs2/localalloc.c
59576 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59577 goto bail;
59578 }
59579
59580 - atomic_inc(&osb->alloc_stats.moves);
59581 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59582
59583 bail:
59584 if (handle)
59585 diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
59586 index f1fc172..452068b 100644
59587 --- a/fs/ocfs2/move_extents.c
59588 +++ b/fs/ocfs2/move_extents.c
59589 @@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
59590 u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
59591 u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
59592
59593 - ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
59594 + ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
59595 p_cpos, new_p_cpos, len);
59596 if (ret) {
59597 mlog_errno(ret);
59598 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59599 index d355e6e..578d905 100644
59600 --- a/fs/ocfs2/ocfs2.h
59601 +++ b/fs/ocfs2/ocfs2.h
59602 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59603
59604 struct ocfs2_alloc_stats
59605 {
59606 - atomic_t moves;
59607 - atomic_t local_data;
59608 - atomic_t bitmap_data;
59609 - atomic_t bg_allocs;
59610 - atomic_t bg_extends;
59611 + atomic_unchecked_t moves;
59612 + atomic_unchecked_t local_data;
59613 + atomic_unchecked_t bitmap_data;
59614 + atomic_unchecked_t bg_allocs;
59615 + atomic_unchecked_t bg_extends;
59616 };
59617
59618 enum ocfs2_local_alloc_state
59619 diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
59620 index 998b17e..aefe414 100644
59621 --- a/fs/ocfs2/refcounttree.c
59622 +++ b/fs/ocfs2/refcounttree.c
59623 @@ -49,7 +49,6 @@
59624
59625 struct ocfs2_cow_context {
59626 struct inode *inode;
59627 - struct file *file;
59628 u32 cow_start;
59629 u32 cow_len;
59630 struct ocfs2_extent_tree data_et;
59631 @@ -66,7 +65,7 @@ struct ocfs2_cow_context {
59632 u32 *num_clusters,
59633 unsigned int *extent_flags);
59634 int (*cow_duplicate_clusters)(handle_t *handle,
59635 - struct file *file,
59636 + struct inode *inode,
59637 u32 cpos, u32 old_cluster,
59638 u32 new_cluster, u32 new_len);
59639 };
59640 @@ -2922,14 +2921,12 @@ static int ocfs2_clear_cow_buffer(handle_t *handle, struct buffer_head *bh)
59641 }
59642
59643 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59644 - struct file *file,
59645 + struct inode *inode,
59646 u32 cpos, u32 old_cluster,
59647 u32 new_cluster, u32 new_len)
59648 {
59649 int ret = 0, partial;
59650 - struct inode *inode = file_inode(file);
59651 - struct ocfs2_caching_info *ci = INODE_CACHE(inode);
59652 - struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
59653 + struct super_block *sb = inode->i_sb;
59654 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
59655 struct page *page;
59656 pgoff_t page_index;
59657 @@ -2973,13 +2970,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59658 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
59659 BUG_ON(PageDirty(page));
59660
59661 - if (PageReadahead(page)) {
59662 - page_cache_async_readahead(mapping,
59663 - &file->f_ra, file,
59664 - page, page_index,
59665 - readahead_pages);
59666 - }
59667 -
59668 if (!PageUptodate(page)) {
59669 ret = block_read_full_page(page, ocfs2_get_block);
59670 if (ret) {
59671 @@ -2999,7 +2989,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59672 }
59673 }
59674
59675 - ocfs2_map_and_dirty_page(inode, handle, from, to,
59676 + ocfs2_map_and_dirty_page(inode,
59677 + handle, from, to,
59678 page, 0, &new_block);
59679 mark_page_accessed(page);
59680 unlock:
59681 @@ -3015,12 +3006,11 @@ unlock:
59682 }
59683
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 {
59690 int ret = 0;
59691 - struct inode *inode = file_inode(file);
59692 struct super_block *sb = inode->i_sb;
59693 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
59694 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
59695 @@ -3145,7 +3135,7 @@ static int ocfs2_replace_clusters(handle_t *handle,
59696
59697 /*If the old clusters is unwritten, no need to duplicate. */
59698 if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) {
59699 - ret = context->cow_duplicate_clusters(handle, context->file,
59700 + ret = context->cow_duplicate_clusters(handle, context->inode,
59701 cpos, old, new, len);
59702 if (ret) {
59703 mlog_errno(ret);
59704 @@ -3423,35 +3413,12 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
59705 return ret;
59706 }
59707
59708 -static void ocfs2_readahead_for_cow(struct inode *inode,
59709 - struct file *file,
59710 - u32 start, u32 len)
59711 -{
59712 - struct address_space *mapping;
59713 - pgoff_t index;
59714 - unsigned long num_pages;
59715 - int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
59716 -
59717 - if (!file)
59718 - return;
59719 -
59720 - mapping = file->f_mapping;
59721 - num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT;
59722 - if (!num_pages)
59723 - num_pages = 1;
59724 -
59725 - index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT;
59726 - page_cache_sync_readahead(mapping, &file->f_ra, file,
59727 - index, num_pages);
59728 -}
59729 -
59730 /*
59731 * Starting at cpos, try to CoW write_len clusters. Don't CoW
59732 * past max_cpos. This will stop when it runs into a hole or an
59733 * unrefcounted extent.
59734 */
59735 static int ocfs2_refcount_cow_hunk(struct inode *inode,
59736 - struct file *file,
59737 struct buffer_head *di_bh,
59738 u32 cpos, u32 write_len, u32 max_cpos)
59739 {
59740 @@ -3480,8 +3447,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
59741
59742 BUG_ON(cow_len == 0);
59743
59744 - ocfs2_readahead_for_cow(inode, file, cow_start, cow_len);
59745 -
59746 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
59747 if (!context) {
59748 ret = -ENOMEM;
59749 @@ -3503,7 +3468,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
59750 context->ref_root_bh = ref_root_bh;
59751 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
59752 context->get_clusters = ocfs2_di_get_clusters;
59753 - context->file = file;
59754
59755 ocfs2_init_dinode_extent_tree(&context->data_et,
59756 INODE_CACHE(inode), di_bh);
59757 @@ -3532,7 +3496,6 @@ out:
59758 * clusters between cpos and cpos+write_len are safe to modify.
59759 */
59760 int ocfs2_refcount_cow(struct inode *inode,
59761 - struct file *file,
59762 struct buffer_head *di_bh,
59763 u32 cpos, u32 write_len, u32 max_cpos)
59764 {
59765 @@ -3552,7 +3515,7 @@ int ocfs2_refcount_cow(struct inode *inode,
59766 num_clusters = write_len;
59767
59768 if (ext_flags & OCFS2_EXT_REFCOUNTED) {
59769 - ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos,
59770 + ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
59771 num_clusters, max_cpos);
59772 if (ret) {
59773 mlog_errno(ret);
59774 diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h
59775 index 7754608..6422bbcdb 100644
59776 --- a/fs/ocfs2/refcounttree.h
59777 +++ b/fs/ocfs2/refcounttree.h
59778 @@ -53,7 +53,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
59779 int *credits,
59780 int *ref_blocks);
59781 int ocfs2_refcount_cow(struct inode *inode,
59782 - struct file *filep, struct buffer_head *di_bh,
59783 + struct buffer_head *di_bh,
59784 u32 cpos, u32 write_len, u32 max_cpos);
59785
59786 typedef int (ocfs2_post_refcount_func)(struct inode *inode,
59787 @@ -85,11 +85,11 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
59788 u32 cpos, u32 write_len,
59789 struct ocfs2_post_refcount *post);
59790 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59791 - struct file *file,
59792 + struct inode *inode,
59793 u32 cpos, u32 old_cluster,
59794 u32 new_cluster, u32 new_len);
59795 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
59796 - struct file *file,
59797 + struct inode *inode,
59798 u32 cpos, u32 old_cluster,
59799 u32 new_cluster, u32 new_len);
59800 int ocfs2_cow_sync_writeback(struct super_block *sb,
59801 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59802 index b7e74b5..19c6536 100644
59803 --- a/fs/ocfs2/suballoc.c
59804 +++ b/fs/ocfs2/suballoc.c
59805 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59806 mlog_errno(status);
59807 goto bail;
59808 }
59809 - atomic_inc(&osb->alloc_stats.bg_extends);
59810 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59811
59812 /* You should never ask for this much metadata */
59813 BUG_ON(bits_wanted >
59814 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59815 mlog_errno(status);
59816 goto bail;
59817 }
59818 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59819 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59820
59821 *suballoc_loc = res.sr_bg_blkno;
59822 *suballoc_bit_start = res.sr_bit_offset;
59823 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59824 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59825 res->sr_bits);
59826
59827 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59828 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59829
59830 BUG_ON(res->sr_bits != 1);
59831
59832 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59833 mlog_errno(status);
59834 goto bail;
59835 }
59836 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59837 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59838
59839 BUG_ON(res.sr_bits != 1);
59840
59841 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59842 cluster_start,
59843 num_clusters);
59844 if (!status)
59845 - atomic_inc(&osb->alloc_stats.local_data);
59846 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59847 } else {
59848 if (min_clusters > (osb->bitmap_cpg - 1)) {
59849 /* The only paths asking for contiguousness
59850 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59851 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59852 res.sr_bg_blkno,
59853 res.sr_bit_offset);
59854 - atomic_inc(&osb->alloc_stats.bitmap_data);
59855 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59856 *num_clusters = res.sr_bits;
59857 }
59858 }
59859 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59860 index 01b8516..579c4df 100644
59861 --- a/fs/ocfs2/super.c
59862 +++ b/fs/ocfs2/super.c
59863 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59864 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59865 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59866 "Stats",
59867 - atomic_read(&osb->alloc_stats.bitmap_data),
59868 - atomic_read(&osb->alloc_stats.local_data),
59869 - atomic_read(&osb->alloc_stats.bg_allocs),
59870 - atomic_read(&osb->alloc_stats.moves),
59871 - atomic_read(&osb->alloc_stats.bg_extends));
59872 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59873 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59874 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59875 + atomic_read_unchecked(&osb->alloc_stats.moves),
59876 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59877
59878 out += snprintf(buf + out, len - out,
59879 "%10s => State: %u Descriptor: %llu Size: %u bits "
59880 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59881 spin_lock_init(&osb->osb_xattr_lock);
59882 ocfs2_init_steal_slots(osb);
59883
59884 - atomic_set(&osb->alloc_stats.moves, 0);
59885 - atomic_set(&osb->alloc_stats.local_data, 0);
59886 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59887 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59888 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59889 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59890 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59891 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59892 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59893 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59894
59895 /* Copy the blockcheck stats from the superblock probe */
59896 osb->osb_ecc_stats = *stats;
59897 diff --git a/fs/open.c b/fs/open.c
59898 index 8c74100..4239c48 100644
59899 --- a/fs/open.c
59900 +++ b/fs/open.c
59901 @@ -32,6 +32,8 @@
59902 #include <linux/dnotify.h>
59903 #include <linux/compat.h>
59904
59905 +#define CREATE_TRACE_POINTS
59906 +#include <trace/events/fs.h>
59907 #include "internal.h"
59908
59909 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59910 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59911 error = locks_verify_truncate(inode, NULL, length);
59912 if (!error)
59913 error = security_path_truncate(path);
59914 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59915 + error = -EACCES;
59916 if (!error)
59917 error = do_truncate(path->dentry, length, 0, NULL);
59918
59919 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59920 error = locks_verify_truncate(inode, f.file, length);
59921 if (!error)
59922 error = security_path_truncate(&f.file->f_path);
59923 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59924 + error = -EACCES;
59925 if (!error)
59926 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59927 sb_end_write(inode->i_sb);
59928 @@ -360,6 +366,9 @@ retry:
59929 if (__mnt_is_readonly(path.mnt))
59930 res = -EROFS;
59931
59932 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59933 + res = -EACCES;
59934 +
59935 out_path_release:
59936 path_put(&path);
59937 if (retry_estale(res, lookup_flags)) {
59938 @@ -391,6 +400,8 @@ retry:
59939 if (error)
59940 goto dput_and_out;
59941
59942 + gr_log_chdir(path.dentry, path.mnt);
59943 +
59944 set_fs_pwd(current->fs, &path);
59945
59946 dput_and_out:
59947 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59948 goto out_putf;
59949
59950 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59951 +
59952 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59953 + error = -EPERM;
59954 +
59955 + if (!error)
59956 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59957 +
59958 if (!error)
59959 set_fs_pwd(current->fs, &f.file->f_path);
59960 out_putf:
59961 @@ -449,7 +467,13 @@ retry:
59962 if (error)
59963 goto dput_and_out;
59964
59965 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59966 + goto dput_and_out;
59967 +
59968 set_fs_root(current->fs, &path);
59969 +
59970 + gr_handle_chroot_chdir(&path);
59971 +
59972 error = 0;
59973 dput_and_out:
59974 path_put(&path);
59975 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59976 if (error)
59977 return error;
59978 mutex_lock(&inode->i_mutex);
59979 +
59980 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59981 + error = -EACCES;
59982 + goto out_unlock;
59983 + }
59984 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59985 + error = -EACCES;
59986 + goto out_unlock;
59987 + }
59988 +
59989 error = security_path_chmod(path, mode);
59990 if (error)
59991 goto out_unlock;
59992 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59993 uid = make_kuid(current_user_ns(), user);
59994 gid = make_kgid(current_user_ns(), group);
59995
59996 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59997 + return -EACCES;
59998 +
59999 newattrs.ia_valid = ATTR_CTIME;
60000 if (user != (uid_t) -1) {
60001 if (!uid_valid(uid))
60002 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
60003 } else {
60004 fsnotify_open(f);
60005 fd_install(fd, f);
60006 + trace_do_sys_open(tmp->name, flags, mode);
60007 }
60008 }
60009 putname(tmp);
60010 diff --git a/fs/pipe.c b/fs/pipe.c
60011 index d2c45e1..009fe1c 100644
60012 --- a/fs/pipe.c
60013 +++ b/fs/pipe.c
60014 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
60015
60016 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
60017 {
60018 - if (pipe->files)
60019 + if (atomic_read(&pipe->files))
60020 mutex_lock_nested(&pipe->mutex, subclass);
60021 }
60022
60023 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
60024
60025 void pipe_unlock(struct pipe_inode_info *pipe)
60026 {
60027 - if (pipe->files)
60028 + if (atomic_read(&pipe->files))
60029 mutex_unlock(&pipe->mutex);
60030 }
60031 EXPORT_SYMBOL(pipe_unlock);
60032 @@ -449,9 +449,9 @@ redo:
60033 }
60034 if (bufs) /* More to do? */
60035 continue;
60036 - if (!pipe->writers)
60037 + if (!atomic_read(&pipe->writers))
60038 break;
60039 - if (!pipe->waiting_writers) {
60040 + if (!atomic_read(&pipe->waiting_writers)) {
60041 /* syscall merging: Usually we must not sleep
60042 * if O_NONBLOCK is set, or if we got some data.
60043 * But if a writer sleeps in kernel space, then
60044 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
60045 ret = 0;
60046 __pipe_lock(pipe);
60047
60048 - if (!pipe->readers) {
60049 + if (!atomic_read(&pipe->readers)) {
60050 send_sig(SIGPIPE, current, 0);
60051 ret = -EPIPE;
60052 goto out;
60053 @@ -562,7 +562,7 @@ redo1:
60054 for (;;) {
60055 int bufs;
60056
60057 - if (!pipe->readers) {
60058 + if (!atomic_read(&pipe->readers)) {
60059 send_sig(SIGPIPE, current, 0);
60060 if (!ret)
60061 ret = -EPIPE;
60062 @@ -653,9 +653,9 @@ redo2:
60063 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60064 do_wakeup = 0;
60065 }
60066 - pipe->waiting_writers++;
60067 + atomic_inc(&pipe->waiting_writers);
60068 pipe_wait(pipe);
60069 - pipe->waiting_writers--;
60070 + atomic_dec(&pipe->waiting_writers);
60071 }
60072 out:
60073 __pipe_unlock(pipe);
60074 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60075 mask = 0;
60076 if (filp->f_mode & FMODE_READ) {
60077 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
60078 - if (!pipe->writers && filp->f_version != pipe->w_counter)
60079 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
60080 mask |= POLLHUP;
60081 }
60082
60083 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60084 * Most Unices do not set POLLERR for FIFOs but on Linux they
60085 * behave exactly like pipes for poll().
60086 */
60087 - if (!pipe->readers)
60088 + if (!atomic_read(&pipe->readers))
60089 mask |= POLLERR;
60090 }
60091
60092 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
60093
60094 __pipe_lock(pipe);
60095 if (file->f_mode & FMODE_READ)
60096 - pipe->readers--;
60097 + atomic_dec(&pipe->readers);
60098 if (file->f_mode & FMODE_WRITE)
60099 - pipe->writers--;
60100 + atomic_dec(&pipe->writers);
60101
60102 - if (pipe->readers || pipe->writers) {
60103 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
60104 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
60105 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60106 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
60107 }
60108 spin_lock(&inode->i_lock);
60109 - if (!--pipe->files) {
60110 + if (atomic_dec_and_test(&pipe->files)) {
60111 inode->i_pipe = NULL;
60112 kill = 1;
60113 }
60114 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
60115 kfree(pipe);
60116 }
60117
60118 -static struct vfsmount *pipe_mnt __read_mostly;
60119 +struct vfsmount *pipe_mnt __read_mostly;
60120
60121 /*
60122 * pipefs_dname() is called from d_path().
60123 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
60124 goto fail_iput;
60125
60126 inode->i_pipe = pipe;
60127 - pipe->files = 2;
60128 - pipe->readers = pipe->writers = 1;
60129 + atomic_set(&pipe->files, 2);
60130 + atomic_set(&pipe->readers, 1);
60131 + atomic_set(&pipe->writers, 1);
60132 inode->i_fop = &pipefifo_fops;
60133
60134 /*
60135 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
60136 spin_lock(&inode->i_lock);
60137 if (inode->i_pipe) {
60138 pipe = inode->i_pipe;
60139 - pipe->files++;
60140 + atomic_inc(&pipe->files);
60141 spin_unlock(&inode->i_lock);
60142 } else {
60143 spin_unlock(&inode->i_lock);
60144 pipe = alloc_pipe_info();
60145 if (!pipe)
60146 return -ENOMEM;
60147 - pipe->files = 1;
60148 + atomic_set(&pipe->files, 1);
60149 spin_lock(&inode->i_lock);
60150 if (unlikely(inode->i_pipe)) {
60151 - inode->i_pipe->files++;
60152 + atomic_inc(&inode->i_pipe->files);
60153 spin_unlock(&inode->i_lock);
60154 free_pipe_info(pipe);
60155 pipe = inode->i_pipe;
60156 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
60157 * opened, even when there is no process writing the FIFO.
60158 */
60159 pipe->r_counter++;
60160 - if (pipe->readers++ == 0)
60161 + if (atomic_inc_return(&pipe->readers) == 1)
60162 wake_up_partner(pipe);
60163
60164 - if (!is_pipe && !pipe->writers) {
60165 + if (!is_pipe && !atomic_read(&pipe->writers)) {
60166 if ((filp->f_flags & O_NONBLOCK)) {
60167 /* suppress POLLHUP until we have
60168 * seen a writer */
60169 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
60170 * errno=ENXIO when there is no process reading the FIFO.
60171 */
60172 ret = -ENXIO;
60173 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
60174 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
60175 goto err;
60176
60177 pipe->w_counter++;
60178 - if (!pipe->writers++)
60179 + if (atomic_inc_return(&pipe->writers) == 1)
60180 wake_up_partner(pipe);
60181
60182 - if (!is_pipe && !pipe->readers) {
60183 + if (!is_pipe && !atomic_read(&pipe->readers)) {
60184 if (wait_for_partner(pipe, &pipe->r_counter))
60185 goto err_wr;
60186 }
60187 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
60188 * the process can at least talk to itself.
60189 */
60190
60191 - pipe->readers++;
60192 - pipe->writers++;
60193 + atomic_inc(&pipe->readers);
60194 + atomic_inc(&pipe->writers);
60195 pipe->r_counter++;
60196 pipe->w_counter++;
60197 - if (pipe->readers == 1 || pipe->writers == 1)
60198 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
60199 wake_up_partner(pipe);
60200 break;
60201
60202 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
60203 return 0;
60204
60205 err_rd:
60206 - if (!--pipe->readers)
60207 + if (atomic_dec_and_test(&pipe->readers))
60208 wake_up_interruptible(&pipe->wait);
60209 ret = -ERESTARTSYS;
60210 goto err;
60211
60212 err_wr:
60213 - if (!--pipe->writers)
60214 + if (atomic_dec_and_test(&pipe->writers))
60215 wake_up_interruptible(&pipe->wait);
60216 ret = -ERESTARTSYS;
60217 goto err;
60218
60219 err:
60220 spin_lock(&inode->i_lock);
60221 - if (!--pipe->files) {
60222 + if (atomic_dec_and_test(&pipe->files)) {
60223 inode->i_pipe = NULL;
60224 kill = 1;
60225 }
60226 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
60227 index 15af622..0e9f4467 100644
60228 --- a/fs/proc/Kconfig
60229 +++ b/fs/proc/Kconfig
60230 @@ -30,12 +30,12 @@ config PROC_FS
60231
60232 config PROC_KCORE
60233 bool "/proc/kcore support" if !ARM
60234 - depends on PROC_FS && MMU
60235 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
60236
60237 config PROC_VMCORE
60238 bool "/proc/vmcore support"
60239 - depends on PROC_FS && CRASH_DUMP
60240 - default y
60241 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
60242 + default n
60243 help
60244 Exports the dump image of crashed kernel in ELF format.
60245
60246 @@ -59,8 +59,8 @@ config PROC_SYSCTL
60247 limited in memory.
60248
60249 config PROC_PAGE_MONITOR
60250 - default y
60251 - depends on PROC_FS && MMU
60252 + default n
60253 + depends on PROC_FS && MMU && !GRKERNSEC
60254 bool "Enable /proc page monitoring" if EXPERT
60255 help
60256 Various /proc files exist to monitor process memory utilization:
60257 diff --git a/fs/proc/array.c b/fs/proc/array.c
60258 index cbd0f1b..adec3f0 100644
60259 --- a/fs/proc/array.c
60260 +++ b/fs/proc/array.c
60261 @@ -60,6 +60,7 @@
60262 #include <linux/tty.h>
60263 #include <linux/string.h>
60264 #include <linux/mman.h>
60265 +#include <linux/grsecurity.h>
60266 #include <linux/proc_fs.h>
60267 #include <linux/ioport.h>
60268 #include <linux/uaccess.h>
60269 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
60270 seq_putc(m, '\n');
60271 }
60272
60273 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60274 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
60275 +{
60276 + if (p->mm)
60277 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
60278 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
60279 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
60280 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
60281 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
60282 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
60283 + else
60284 + seq_printf(m, "PaX:\t-----\n");
60285 +}
60286 +#endif
60287 +
60288 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60289 struct pid *pid, struct task_struct *task)
60290 {
60291 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60292 task_cpus_allowed(m, task);
60293 cpuset_task_status_allowed(m, task);
60294 task_context_switch_counts(m, task);
60295 +
60296 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60297 + task_pax(m, task);
60298 +#endif
60299 +
60300 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
60301 + task_grsec_rbac(m, task);
60302 +#endif
60303 +
60304 return 0;
60305 }
60306
60307 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60308 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60309 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60310 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60311 +#endif
60312 +
60313 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60314 struct pid *pid, struct task_struct *task, int whole)
60315 {
60316 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60317 char tcomm[sizeof(task->comm)];
60318 unsigned long flags;
60319
60320 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60321 + if (current->exec_id != m->exec_id) {
60322 + gr_log_badprocpid("stat");
60323 + return 0;
60324 + }
60325 +#endif
60326 +
60327 state = *get_task_state(task);
60328 vsize = eip = esp = 0;
60329 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60330 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60331 gtime = task_gtime(task);
60332 }
60333
60334 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60335 + if (PAX_RAND_FLAGS(mm)) {
60336 + eip = 0;
60337 + esp = 0;
60338 + wchan = 0;
60339 + }
60340 +#endif
60341 +#ifdef CONFIG_GRKERNSEC_HIDESYM
60342 + wchan = 0;
60343 + eip =0;
60344 + esp =0;
60345 +#endif
60346 +
60347 /* scale priority and nice values from timeslices to -20..20 */
60348 /* to make it look like a "normal" Unix priority/nice value */
60349 priority = task_prio(task);
60350 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60351 seq_put_decimal_ull(m, ' ', vsize);
60352 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
60353 seq_put_decimal_ull(m, ' ', rsslim);
60354 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60355 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
60356 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
60357 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
60358 +#else
60359 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
60360 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
60361 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
60362 +#endif
60363 seq_put_decimal_ull(m, ' ', esp);
60364 seq_put_decimal_ull(m, ' ', eip);
60365 /* The signal information here is obsolete.
60366 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60367 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
60368 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
60369
60370 - if (mm && permitted) {
60371 + if (mm && permitted
60372 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60373 + && !PAX_RAND_FLAGS(mm)
60374 +#endif
60375 + ) {
60376 seq_put_decimal_ull(m, ' ', mm->start_data);
60377 seq_put_decimal_ull(m, ' ', mm->end_data);
60378 seq_put_decimal_ull(m, ' ', mm->start_brk);
60379 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60380 struct pid *pid, struct task_struct *task)
60381 {
60382 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
60383 - struct mm_struct *mm = get_task_mm(task);
60384 + struct mm_struct *mm;
60385
60386 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60387 + if (current->exec_id != m->exec_id) {
60388 + gr_log_badprocpid("statm");
60389 + return 0;
60390 + }
60391 +#endif
60392 + mm = get_task_mm(task);
60393 if (mm) {
60394 size = task_statm(mm, &shared, &text, &data, &resident);
60395 mmput(mm);
60396 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60397 return 0;
60398 }
60399
60400 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60401 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
60402 +{
60403 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
60404 +}
60405 +#endif
60406 +
60407 #ifdef CONFIG_CHECKPOINT_RESTORE
60408 static struct pid *
60409 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
60410 diff --git a/fs/proc/base.c b/fs/proc/base.c
60411 index c3834da..b402b2b 100644
60412 --- a/fs/proc/base.c
60413 +++ b/fs/proc/base.c
60414 @@ -113,6 +113,14 @@ struct pid_entry {
60415 union proc_op op;
60416 };
60417
60418 +struct getdents_callback {
60419 + struct linux_dirent __user * current_dir;
60420 + struct linux_dirent __user * previous;
60421 + struct file * file;
60422 + int count;
60423 + int error;
60424 +};
60425 +
60426 #define NOD(NAME, MODE, IOP, FOP, OP) { \
60427 .name = (NAME), \
60428 .len = sizeof(NAME) - 1, \
60429 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
60430 if (!mm->arg_end)
60431 goto out_mm; /* Shh! No looking before we're done */
60432
60433 + if (gr_acl_handle_procpidmem(task))
60434 + goto out_mm;
60435 +
60436 len = mm->arg_end - mm->arg_start;
60437
60438 if (len > PAGE_SIZE)
60439 @@ -237,12 +248,28 @@ out:
60440 return res;
60441 }
60442
60443 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60444 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60445 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60446 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60447 +#endif
60448 +
60449 static int proc_pid_auxv(struct task_struct *task, char *buffer)
60450 {
60451 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
60452 int res = PTR_ERR(mm);
60453 if (mm && !IS_ERR(mm)) {
60454 unsigned int nwords = 0;
60455 +
60456 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60457 + /* allow if we're currently ptracing this task */
60458 + if (PAX_RAND_FLAGS(mm) &&
60459 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
60460 + mmput(mm);
60461 + return 0;
60462 + }
60463 +#endif
60464 +
60465 do {
60466 nwords += 2;
60467 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
60468 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
60469 }
60470
60471
60472 -#ifdef CONFIG_KALLSYMS
60473 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60474 /*
60475 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
60476 * Returns the resolved symbol. If that fails, simply return the address.
60477 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
60478 mutex_unlock(&task->signal->cred_guard_mutex);
60479 }
60480
60481 -#ifdef CONFIG_STACKTRACE
60482 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60483
60484 #define MAX_STACK_TRACE_DEPTH 64
60485
60486 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
60487 return count;
60488 }
60489
60490 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60491 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60492 static int proc_pid_syscall(struct task_struct *task, char *buffer)
60493 {
60494 long nr;
60495 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
60496 /************************************************************************/
60497
60498 /* permission checks */
60499 -static int proc_fd_access_allowed(struct inode *inode)
60500 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
60501 {
60502 struct task_struct *task;
60503 int allowed = 0;
60504 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
60505 */
60506 task = get_proc_task(inode);
60507 if (task) {
60508 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60509 + if (log)
60510 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60511 + else
60512 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60513 put_task_struct(task);
60514 }
60515 return allowed;
60516 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
60517 struct task_struct *task,
60518 int hide_pid_min)
60519 {
60520 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60521 + return false;
60522 +
60523 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60524 + rcu_read_lock();
60525 + {
60526 + const struct cred *tmpcred = current_cred();
60527 + const struct cred *cred = __task_cred(task);
60528 +
60529 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
60530 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60531 + || in_group_p(grsec_proc_gid)
60532 +#endif
60533 + ) {
60534 + rcu_read_unlock();
60535 + return true;
60536 + }
60537 + }
60538 + rcu_read_unlock();
60539 +
60540 + if (!pid->hide_pid)
60541 + return false;
60542 +#endif
60543 +
60544 if (pid->hide_pid < hide_pid_min)
60545 return true;
60546 if (in_group_p(pid->pid_gid))
60547 return true;
60548 +
60549 return ptrace_may_access(task, PTRACE_MODE_READ);
60550 }
60551
60552 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
60553 put_task_struct(task);
60554
60555 if (!has_perms) {
60556 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60557 + {
60558 +#else
60559 if (pid->hide_pid == 2) {
60560 +#endif
60561 /*
60562 * Let's make getdents(), stat(), and open()
60563 * consistent with each other. If a process
60564 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60565 if (!task)
60566 return -ESRCH;
60567
60568 + if (gr_acl_handle_procpidmem(task)) {
60569 + put_task_struct(task);
60570 + return -EPERM;
60571 + }
60572 +
60573 mm = mm_access(task, mode);
60574 put_task_struct(task);
60575
60576 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60577
60578 file->private_data = mm;
60579
60580 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60581 + file->f_version = current->exec_id;
60582 +#endif
60583 +
60584 return 0;
60585 }
60586
60587 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60588 ssize_t copied;
60589 char *page;
60590
60591 +#ifdef CONFIG_GRKERNSEC
60592 + if (write)
60593 + return -EPERM;
60594 +#endif
60595 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60596 + if (file->f_version != current->exec_id) {
60597 + gr_log_badprocpid("mem");
60598 + return 0;
60599 + }
60600 +#endif
60601 +
60602 if (!mm)
60603 return 0;
60604
60605 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60606 goto free;
60607
60608 while (count > 0) {
60609 - int this_len = min_t(int, count, PAGE_SIZE);
60610 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
60611
60612 if (write && copy_from_user(page, buf, this_len)) {
60613 copied = -EFAULT;
60614 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60615 if (!mm)
60616 return 0;
60617
60618 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60619 + if (file->f_version != current->exec_id) {
60620 + gr_log_badprocpid("environ");
60621 + return 0;
60622 + }
60623 +#endif
60624 +
60625 page = (char *)__get_free_page(GFP_TEMPORARY);
60626 if (!page)
60627 return -ENOMEM;
60628 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60629 goto free;
60630 while (count > 0) {
60631 size_t this_len, max_len;
60632 - int retval;
60633 + ssize_t retval;
60634
60635 if (src >= (mm->env_end - mm->env_start))
60636 break;
60637 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
60638 int error = -EACCES;
60639
60640 /* Are we allowed to snoop on the tasks file descriptors? */
60641 - if (!proc_fd_access_allowed(inode))
60642 + if (!proc_fd_access_allowed(inode, 0))
60643 goto out;
60644
60645 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60646 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
60647 struct path path;
60648
60649 /* Are we allowed to snoop on the tasks file descriptors? */
60650 - if (!proc_fd_access_allowed(inode))
60651 - goto out;
60652 + /* logging this is needed for learning on chromium to work properly,
60653 + but we don't want to flood the logs from 'ps' which does a readlink
60654 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
60655 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
60656 + */
60657 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
60658 + if (!proc_fd_access_allowed(inode,0))
60659 + goto out;
60660 + } else {
60661 + if (!proc_fd_access_allowed(inode,1))
60662 + goto out;
60663 + }
60664
60665 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60666 if (error)
60667 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
60668 rcu_read_lock();
60669 cred = __task_cred(task);
60670 inode->i_uid = cred->euid;
60671 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60672 + inode->i_gid = grsec_proc_gid;
60673 +#else
60674 inode->i_gid = cred->egid;
60675 +#endif
60676 rcu_read_unlock();
60677 }
60678 security_task_to_inode(task, inode);
60679 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
60680 return -ENOENT;
60681 }
60682 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60683 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60684 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60685 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60686 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60687 +#endif
60688 task_dumpable(task)) {
60689 cred = __task_cred(task);
60690 stat->uid = cred->euid;
60691 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60692 + stat->gid = grsec_proc_gid;
60693 +#else
60694 stat->gid = cred->egid;
60695 +#endif
60696 }
60697 }
60698 rcu_read_unlock();
60699 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
60700
60701 if (task) {
60702 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60703 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60704 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60705 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60706 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60707 +#endif
60708 task_dumpable(task)) {
60709 rcu_read_lock();
60710 cred = __task_cred(task);
60711 inode->i_uid = cred->euid;
60712 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60713 + inode->i_gid = grsec_proc_gid;
60714 +#else
60715 inode->i_gid = cred->egid;
60716 +#endif
60717 rcu_read_unlock();
60718 } else {
60719 inode->i_uid = GLOBAL_ROOT_UID;
60720 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60721 if (!task)
60722 goto out_no_task;
60723
60724 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60725 + goto out;
60726 +
60727 /*
60728 * Yes, it does not scale. And it should not. Don't add
60729 * new entries into /proc/<tgid>/ without very good reasons.
60730 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
60731 if (!task)
60732 goto out_no_task;
60733
60734 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60735 + goto out;
60736 +
60737 ret = 0;
60738 i = filp->f_pos;
60739 switch (i) {
60740 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60741 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60742 #endif
60743 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60744 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60745 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60746 INF("syscall", S_IRUGO, proc_pid_syscall),
60747 #endif
60748 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60749 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60750 #ifdef CONFIG_SECURITY
60751 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60752 #endif
60753 -#ifdef CONFIG_KALLSYMS
60754 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60755 INF("wchan", S_IRUGO, proc_pid_wchan),
60756 #endif
60757 -#ifdef CONFIG_STACKTRACE
60758 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60759 ONE("stack", S_IRUGO, proc_pid_stack),
60760 #endif
60761 #ifdef CONFIG_SCHEDSTATS
60762 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60763 #ifdef CONFIG_HARDWALL
60764 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60765 #endif
60766 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60767 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60768 +#endif
60769 #ifdef CONFIG_USER_NS
60770 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60771 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60772 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
60773 if (!inode)
60774 goto out;
60775
60776 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60777 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60778 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60779 + inode->i_gid = grsec_proc_gid;
60780 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60781 +#else
60782 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60783 +#endif
60784 inode->i_op = &proc_tgid_base_inode_operations;
60785 inode->i_fop = &proc_tgid_base_operations;
60786 inode->i_flags|=S_IMMUTABLE;
60787 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60788 if (!task)
60789 goto out;
60790
60791 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60792 + goto out_put_task;
60793 +
60794 result = proc_pid_instantiate(dir, dentry, task, NULL);
60795 +out_put_task:
60796 put_task_struct(task);
60797 out:
60798 return result;
60799 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
60800 static int fake_filldir(void *buf, const char *name, int namelen,
60801 loff_t offset, u64 ino, unsigned d_type)
60802 {
60803 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
60804 + __buf->error = -EINVAL;
60805 return 0;
60806 }
60807
60808 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
60809 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60810 #endif
60811 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60812 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60813 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60814 INF("syscall", S_IRUGO, proc_pid_syscall),
60815 #endif
60816 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60817 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
60818 #ifdef CONFIG_SECURITY
60819 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60820 #endif
60821 -#ifdef CONFIG_KALLSYMS
60822 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60823 INF("wchan", S_IRUGO, proc_pid_wchan),
60824 #endif
60825 -#ifdef CONFIG_STACKTRACE
60826 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60827 ONE("stack", S_IRUGO, proc_pid_stack),
60828 #endif
60829 #ifdef CONFIG_SCHEDSTATS
60830 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60831 index 82676e3..5f8518a 100644
60832 --- a/fs/proc/cmdline.c
60833 +++ b/fs/proc/cmdline.c
60834 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60835
60836 static int __init proc_cmdline_init(void)
60837 {
60838 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60839 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60840 +#else
60841 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60842 +#endif
60843 return 0;
60844 }
60845 module_init(proc_cmdline_init);
60846 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60847 index b143471..bb105e5 100644
60848 --- a/fs/proc/devices.c
60849 +++ b/fs/proc/devices.c
60850 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60851
60852 static int __init proc_devices_init(void)
60853 {
60854 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60855 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60856 +#else
60857 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60858 +#endif
60859 return 0;
60860 }
60861 module_init(proc_devices_init);
60862 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60863 index d7a4a28..0201742 100644
60864 --- a/fs/proc/fd.c
60865 +++ b/fs/proc/fd.c
60866 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60867 if (!task)
60868 return -ENOENT;
60869
60870 - files = get_files_struct(task);
60871 + if (!gr_acl_handle_procpidmem(task))
60872 + files = get_files_struct(task);
60873 put_task_struct(task);
60874
60875 if (files) {
60876 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60877 */
60878 int proc_fd_permission(struct inode *inode, int mask)
60879 {
60880 + struct task_struct *task;
60881 int rv = generic_permission(inode, mask);
60882 - if (rv == 0)
60883 - return 0;
60884 +
60885 if (task_pid(current) == proc_pid(inode))
60886 rv = 0;
60887 +
60888 + task = get_proc_task(inode);
60889 + if (task == NULL)
60890 + return rv;
60891 +
60892 + if (gr_acl_handle_procpidmem(task))
60893 + rv = -EACCES;
60894 +
60895 + put_task_struct(task);
60896 +
60897 return rv;
60898 }
60899
60900 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60901 index 073aea6..0630370 100644
60902 --- a/fs/proc/inode.c
60903 +++ b/fs/proc/inode.c
60904 @@ -23,11 +23,17 @@
60905 #include <linux/slab.h>
60906 #include <linux/mount.h>
60907 #include <linux/magic.h>
60908 +#include <linux/grsecurity.h>
60909
60910 #include <asm/uaccess.h>
60911
60912 #include "internal.h"
60913
60914 +#ifdef CONFIG_PROC_SYSCTL
60915 +extern const struct inode_operations proc_sys_inode_operations;
60916 +extern const struct inode_operations proc_sys_dir_operations;
60917 +#endif
60918 +
60919 static void proc_evict_inode(struct inode *inode)
60920 {
60921 struct proc_dir_entry *de;
60922 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60923 ns = PROC_I(inode)->ns.ns;
60924 if (ns_ops && ns)
60925 ns_ops->put(ns);
60926 +
60927 +#ifdef CONFIG_PROC_SYSCTL
60928 + if (inode->i_op == &proc_sys_inode_operations ||
60929 + inode->i_op == &proc_sys_dir_operations)
60930 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60931 +#endif
60932 +
60933 }
60934
60935 static struct kmem_cache * proc_inode_cachep;
60936 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60937 if (de->mode) {
60938 inode->i_mode = de->mode;
60939 inode->i_uid = de->uid;
60940 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60941 + inode->i_gid = grsec_proc_gid;
60942 +#else
60943 inode->i_gid = de->gid;
60944 +#endif
60945 }
60946 if (de->size)
60947 inode->i_size = de->size;
60948 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60949 index d600fb0..3b495fe 100644
60950 --- a/fs/proc/internal.h
60951 +++ b/fs/proc/internal.h
60952 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60953 struct pid *, struct task_struct *);
60954 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60955 struct pid *, struct task_struct *);
60956 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60957 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60958 +#endif
60959
60960 /*
60961 * base.c
60962 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60963 index 0a22194..a9fc8c1 100644
60964 --- a/fs/proc/kcore.c
60965 +++ b/fs/proc/kcore.c
60966 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60967 * the addresses in the elf_phdr on our list.
60968 */
60969 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60970 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60971 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60972 + if (tsz > buflen)
60973 tsz = buflen;
60974 -
60975 +
60976 while (buflen) {
60977 struct kcore_list *m;
60978
60979 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60980 kfree(elf_buf);
60981 } else {
60982 if (kern_addr_valid(start)) {
60983 - unsigned long n;
60984 + char *elf_buf;
60985 + mm_segment_t oldfs;
60986
60987 - n = copy_to_user(buffer, (char *)start, tsz);
60988 - /*
60989 - * We cannot distinguish between fault on source
60990 - * and fault on destination. When this happens
60991 - * we clear too and hope it will trigger the
60992 - * EFAULT again.
60993 - */
60994 - if (n) {
60995 - if (clear_user(buffer + tsz - n,
60996 - n))
60997 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60998 + if (!elf_buf)
60999 + return -ENOMEM;
61000 + oldfs = get_fs();
61001 + set_fs(KERNEL_DS);
61002 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
61003 + set_fs(oldfs);
61004 + if (copy_to_user(buffer, elf_buf, tsz)) {
61005 + kfree(elf_buf);
61006 return -EFAULT;
61007 + }
61008 }
61009 + set_fs(oldfs);
61010 + kfree(elf_buf);
61011 } else {
61012 if (clear_user(buffer, tsz))
61013 return -EFAULT;
61014 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
61015
61016 static int open_kcore(struct inode *inode, struct file *filp)
61017 {
61018 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
61019 + return -EPERM;
61020 +#endif
61021 if (!capable(CAP_SYS_RAWIO))
61022 return -EPERM;
61023 if (kcore_need_update)
61024 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
61025 index 5aa847a..f77c8d4 100644
61026 --- a/fs/proc/meminfo.c
61027 +++ b/fs/proc/meminfo.c
61028 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
61029 vmi.used >> 10,
61030 vmi.largest_chunk >> 10
61031 #ifdef CONFIG_MEMORY_FAILURE
61032 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
61033 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
61034 #endif
61035 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
61036 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
61037 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
61038 index ccfd99b..1b7e255 100644
61039 --- a/fs/proc/nommu.c
61040 +++ b/fs/proc/nommu.c
61041 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
61042 if (len < 1)
61043 len = 1;
61044 seq_printf(m, "%*c", len, ' ');
61045 - seq_path(m, &file->f_path, "");
61046 + seq_path(m, &file->f_path, "\n\\");
61047 }
61048
61049 seq_putc(m, '\n');
61050 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
61051 index 986e832..6e8e859 100644
61052 --- a/fs/proc/proc_net.c
61053 +++ b/fs/proc/proc_net.c
61054 @@ -23,6 +23,7 @@
61055 #include <linux/nsproxy.h>
61056 #include <net/net_namespace.h>
61057 #include <linux/seq_file.h>
61058 +#include <linux/grsecurity.h>
61059
61060 #include "internal.h"
61061
61062 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
61063 struct task_struct *task;
61064 struct nsproxy *ns;
61065 struct net *net = NULL;
61066 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61067 + const struct cred *cred = current_cred();
61068 +#endif
61069 +
61070 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61071 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
61072 + return net;
61073 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61074 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
61075 + return net;
61076 +#endif
61077
61078 rcu_read_lock();
61079 task = pid_task(proc_pid(dir), PIDTYPE_PID);
61080 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
61081 index ac05f33..1e6dc7e 100644
61082 --- a/fs/proc/proc_sysctl.c
61083 +++ b/fs/proc/proc_sysctl.c
61084 @@ -13,11 +13,15 @@
61085 #include <linux/module.h>
61086 #include "internal.h"
61087
61088 +extern int gr_handle_chroot_sysctl(const int op);
61089 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
61090 + const int op);
61091 +
61092 static const struct dentry_operations proc_sys_dentry_operations;
61093 static const struct file_operations proc_sys_file_operations;
61094 -static const struct inode_operations proc_sys_inode_operations;
61095 +const struct inode_operations proc_sys_inode_operations;
61096 static const struct file_operations proc_sys_dir_file_operations;
61097 -static const struct inode_operations proc_sys_dir_operations;
61098 +const struct inode_operations proc_sys_dir_operations;
61099
61100 void proc_sys_poll_notify(struct ctl_table_poll *poll)
61101 {
61102 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
61103
61104 err = NULL;
61105 d_set_d_op(dentry, &proc_sys_dentry_operations);
61106 +
61107 + gr_handle_proc_create(dentry, inode);
61108 +
61109 d_add(dentry, inode);
61110
61111 out:
61112 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61113 struct inode *inode = file_inode(filp);
61114 struct ctl_table_header *head = grab_header(inode);
61115 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
61116 + int op = write ? MAY_WRITE : MAY_READ;
61117 ssize_t error;
61118 size_t res;
61119
61120 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61121 * and won't be until we finish.
61122 */
61123 error = -EPERM;
61124 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
61125 + if (sysctl_perm(head, table, op))
61126 goto out;
61127
61128 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
61129 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61130 if (!table->proc_handler)
61131 goto out;
61132
61133 +#ifdef CONFIG_GRKERNSEC
61134 + error = -EPERM;
61135 + if (gr_handle_chroot_sysctl(op))
61136 + goto out;
61137 + dget(filp->f_path.dentry);
61138 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
61139 + dput(filp->f_path.dentry);
61140 + goto out;
61141 + }
61142 + dput(filp->f_path.dentry);
61143 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
61144 + goto out;
61145 + if (write && !capable(CAP_SYS_ADMIN))
61146 + goto out;
61147 +#endif
61148 +
61149 /* careful: calling conventions are nasty here */
61150 res = count;
61151 error = table->proc_handler(table, write, buf, &res, ppos);
61152 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
61153 return -ENOMEM;
61154 } else {
61155 d_set_d_op(child, &proc_sys_dentry_operations);
61156 +
61157 + gr_handle_proc_create(child, inode);
61158 +
61159 d_add(child, inode);
61160 }
61161 } else {
61162 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
61163 if ((*pos)++ < file->f_pos)
61164 return 0;
61165
61166 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
61167 + return 0;
61168 +
61169 if (unlikely(S_ISLNK(table->mode)))
61170 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
61171 else
61172 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
61173 if (IS_ERR(head))
61174 return PTR_ERR(head);
61175
61176 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
61177 + return -ENOENT;
61178 +
61179 generic_fillattr(inode, stat);
61180 if (table)
61181 stat->mode = (stat->mode & S_IFMT) | table->mode;
61182 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
61183 .llseek = generic_file_llseek,
61184 };
61185
61186 -static const struct inode_operations proc_sys_inode_operations = {
61187 +const struct inode_operations proc_sys_inode_operations = {
61188 .permission = proc_sys_permission,
61189 .setattr = proc_sys_setattr,
61190 .getattr = proc_sys_getattr,
61191 };
61192
61193 -static const struct inode_operations proc_sys_dir_operations = {
61194 +const struct inode_operations proc_sys_dir_operations = {
61195 .lookup = proc_sys_lookup,
61196 .permission = proc_sys_permission,
61197 .setattr = proc_sys_setattr,
61198 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
61199 static struct ctl_dir *new_dir(struct ctl_table_set *set,
61200 const char *name, int namelen)
61201 {
61202 - struct ctl_table *table;
61203 + ctl_table_no_const *table;
61204 struct ctl_dir *new;
61205 struct ctl_node *node;
61206 char *new_name;
61207 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
61208 return NULL;
61209
61210 node = (struct ctl_node *)(new + 1);
61211 - table = (struct ctl_table *)(node + 1);
61212 + table = (ctl_table_no_const *)(node + 1);
61213 new_name = (char *)(table + 2);
61214 memcpy(new_name, name, namelen);
61215 new_name[namelen] = '\0';
61216 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
61217 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
61218 struct ctl_table_root *link_root)
61219 {
61220 - struct ctl_table *link_table, *entry, *link;
61221 + ctl_table_no_const *link_table, *link;
61222 + struct ctl_table *entry;
61223 struct ctl_table_header *links;
61224 struct ctl_node *node;
61225 char *link_name;
61226 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
61227 return NULL;
61228
61229 node = (struct ctl_node *)(links + 1);
61230 - link_table = (struct ctl_table *)(node + nr_entries);
61231 + link_table = (ctl_table_no_const *)(node + nr_entries);
61232 link_name = (char *)&link_table[nr_entries + 1];
61233
61234 for (link = link_table, entry = table; entry->procname; link++, entry++) {
61235 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61236 struct ctl_table_header ***subheader, struct ctl_table_set *set,
61237 struct ctl_table *table)
61238 {
61239 - struct ctl_table *ctl_table_arg = NULL;
61240 - struct ctl_table *entry, *files;
61241 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
61242 + struct ctl_table *entry;
61243 int nr_files = 0;
61244 int nr_dirs = 0;
61245 int err = -ENOMEM;
61246 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61247 nr_files++;
61248 }
61249
61250 - files = table;
61251 /* If there are mixed files and directories we need a new table */
61252 if (nr_dirs && nr_files) {
61253 - struct ctl_table *new;
61254 + ctl_table_no_const *new;
61255 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
61256 GFP_KERNEL);
61257 if (!files)
61258 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61259 /* Register everything except a directory full of subdirectories */
61260 if (nr_files || !nr_dirs) {
61261 struct ctl_table_header *header;
61262 - header = __register_sysctl_table(set, path, files);
61263 + header = __register_sysctl_table(set, path, files ? files : table);
61264 if (!header) {
61265 kfree(ctl_table_arg);
61266 goto out;
61267 diff --git a/fs/proc/root.c b/fs/proc/root.c
61268 index 41a6ea9..23eaa92 100644
61269 --- a/fs/proc/root.c
61270 +++ b/fs/proc/root.c
61271 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
61272 #ifdef CONFIG_PROC_DEVICETREE
61273 proc_device_tree_init();
61274 #endif
61275 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61276 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61277 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
61278 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61279 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
61280 +#endif
61281 +#else
61282 proc_mkdir("bus", NULL);
61283 +#endif
61284 proc_sys_init();
61285 }
61286
61287 diff --git a/fs/proc/self.c b/fs/proc/self.c
61288 index 6b6a993..807cccc 100644
61289 --- a/fs/proc/self.c
61290 +++ b/fs/proc/self.c
61291 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
61292 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
61293 void *cookie)
61294 {
61295 - char *s = nd_get_link(nd);
61296 + const char *s = nd_get_link(nd);
61297 if (!IS_ERR(s))
61298 kfree(s);
61299 }
61300 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
61301 index 65fc60a..350cc48 100644
61302 --- a/fs/proc/task_mmu.c
61303 +++ b/fs/proc/task_mmu.c
61304 @@ -11,12 +11,19 @@
61305 #include <linux/rmap.h>
61306 #include <linux/swap.h>
61307 #include <linux/swapops.h>
61308 +#include <linux/grsecurity.h>
61309
61310 #include <asm/elf.h>
61311 #include <asm/uaccess.h>
61312 #include <asm/tlbflush.h>
61313 #include "internal.h"
61314
61315 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61316 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
61317 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
61318 + _mm->pax_flags & MF_PAX_SEGMEXEC))
61319 +#endif
61320 +
61321 void task_mem(struct seq_file *m, struct mm_struct *mm)
61322 {
61323 unsigned long data, text, lib, swap;
61324 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61325 "VmExe:\t%8lu kB\n"
61326 "VmLib:\t%8lu kB\n"
61327 "VmPTE:\t%8lu kB\n"
61328 - "VmSwap:\t%8lu kB\n",
61329 - hiwater_vm << (PAGE_SHIFT-10),
61330 + "VmSwap:\t%8lu kB\n"
61331 +
61332 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61333 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
61334 +#endif
61335 +
61336 + ,hiwater_vm << (PAGE_SHIFT-10),
61337 total_vm << (PAGE_SHIFT-10),
61338 mm->locked_vm << (PAGE_SHIFT-10),
61339 mm->pinned_vm << (PAGE_SHIFT-10),
61340 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61341 data << (PAGE_SHIFT-10),
61342 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
61343 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
61344 - swap << (PAGE_SHIFT-10));
61345 + swap << (PAGE_SHIFT-10)
61346 +
61347 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61348 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61349 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
61350 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
61351 +#else
61352 + , mm->context.user_cs_base
61353 + , mm->context.user_cs_limit
61354 +#endif
61355 +#endif
61356 +
61357 + );
61358 }
61359
61360 unsigned long task_vsize(struct mm_struct *mm)
61361 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61362 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
61363 }
61364
61365 - /* We don't show the stack guard page in /proc/maps */
61366 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61367 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
61368 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
61369 +#else
61370 start = vma->vm_start;
61371 - if (stack_guard_page_start(vma, start))
61372 - start += PAGE_SIZE;
61373 end = vma->vm_end;
61374 - if (stack_guard_page_end(vma, end))
61375 - end -= PAGE_SIZE;
61376 +#endif
61377
61378 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
61379 start,
61380 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61381 flags & VM_WRITE ? 'w' : '-',
61382 flags & VM_EXEC ? 'x' : '-',
61383 flags & VM_MAYSHARE ? 's' : 'p',
61384 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61385 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
61386 +#else
61387 pgoff,
61388 +#endif
61389 MAJOR(dev), MINOR(dev), ino, &len);
61390
61391 /*
61392 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61393 */
61394 if (file) {
61395 pad_len_spaces(m, len);
61396 - seq_path(m, &file->f_path, "\n");
61397 + seq_path(m, &file->f_path, "\n\\");
61398 goto done;
61399 }
61400
61401 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61402 * Thread stack in /proc/PID/task/TID/maps or
61403 * the main process stack.
61404 */
61405 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
61406 - vma->vm_end >= mm->start_stack)) {
61407 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
61408 + (vma->vm_start <= mm->start_stack &&
61409 + vma->vm_end >= mm->start_stack)) {
61410 name = "[stack]";
61411 } else {
61412 /* Thread stack in /proc/PID/maps */
61413 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
61414 struct proc_maps_private *priv = m->private;
61415 struct task_struct *task = priv->task;
61416
61417 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61418 + if (current->exec_id != m->exec_id) {
61419 + gr_log_badprocpid("maps");
61420 + return 0;
61421 + }
61422 +#endif
61423 +
61424 show_map_vma(m, vma, is_pid);
61425
61426 if (m->count < m->size) /* vma is copied successfully */
61427 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61428 .private = &mss,
61429 };
61430
61431 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61432 + if (current->exec_id != m->exec_id) {
61433 + gr_log_badprocpid("smaps");
61434 + return 0;
61435 + }
61436 +#endif
61437 memset(&mss, 0, sizeof mss);
61438 - mss.vma = vma;
61439 - /* mmap_sem is held in m_start */
61440 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61441 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61442 -
61443 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61444 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
61445 +#endif
61446 + mss.vma = vma;
61447 + /* mmap_sem is held in m_start */
61448 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61449 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61450 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61451 + }
61452 +#endif
61453 show_map_vma(m, vma, is_pid);
61454
61455 seq_printf(m,
61456 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61457 "KernelPageSize: %8lu kB\n"
61458 "MMUPageSize: %8lu kB\n"
61459 "Locked: %8lu kB\n",
61460 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61461 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
61462 +#else
61463 (vma->vm_end - vma->vm_start) >> 10,
61464 +#endif
61465 mss.resident >> 10,
61466 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
61467 mss.shared_clean >> 10,
61468 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61469 int n;
61470 char buffer[50];
61471
61472 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61473 + if (current->exec_id != m->exec_id) {
61474 + gr_log_badprocpid("numa_maps");
61475 + return 0;
61476 + }
61477 +#endif
61478 +
61479 if (!mm)
61480 return 0;
61481
61482 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61483 mpol_to_str(buffer, sizeof(buffer), pol);
61484 mpol_cond_put(pol);
61485
61486 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61487 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
61488 +#else
61489 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
61490 +#endif
61491
61492 if (file) {
61493 seq_printf(m, " file=");
61494 - seq_path(m, &file->f_path, "\n\t= ");
61495 + seq_path(m, &file->f_path, "\n\t\\= ");
61496 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
61497 seq_printf(m, " heap");
61498 } else {
61499 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
61500 index 56123a6..5a2f6ec 100644
61501 --- a/fs/proc/task_nommu.c
61502 +++ b/fs/proc/task_nommu.c
61503 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61504 else
61505 bytes += kobjsize(mm);
61506
61507 - if (current->fs && current->fs->users > 1)
61508 + if (current->fs && atomic_read(&current->fs->users) > 1)
61509 sbytes += kobjsize(current->fs);
61510 else
61511 bytes += kobjsize(current->fs);
61512 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
61513
61514 if (file) {
61515 pad_len_spaces(m, len);
61516 - seq_path(m, &file->f_path, "");
61517 + seq_path(m, &file->f_path, "\n\\");
61518 } else if (mm) {
61519 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
61520
61521 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
61522 index 17f7e08..e4b1529 100644
61523 --- a/fs/proc/vmcore.c
61524 +++ b/fs/proc/vmcore.c
61525 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
61526 nr_bytes = count;
61527
61528 /* If pfn is not ram, return zeros for sparse dump files */
61529 - if (pfn_is_ram(pfn) == 0)
61530 - memset(buf, 0, nr_bytes);
61531 - else {
61532 + if (pfn_is_ram(pfn) == 0) {
61533 + if (userbuf) {
61534 + if (clear_user((char __force_user *)buf, nr_bytes))
61535 + return -EFAULT;
61536 + } else
61537 + memset(buf, 0, nr_bytes);
61538 + } else {
61539 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
61540 offset, userbuf);
61541 if (tmp < 0)
61542 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
61543 if (tsz > nr_bytes)
61544 tsz = nr_bytes;
61545
61546 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
61547 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
61548 if (tmp < 0)
61549 return tmp;
61550 buflen -= tsz;
61551 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
61552 index b00fcc9..e0c6381 100644
61553 --- a/fs/qnx6/qnx6.h
61554 +++ b/fs/qnx6/qnx6.h
61555 @@ -74,7 +74,7 @@ enum {
61556 BYTESEX_BE,
61557 };
61558
61559 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61560 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61561 {
61562 if (sbi->s_bytesex == BYTESEX_LE)
61563 return le64_to_cpu((__force __le64)n);
61564 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
61565 return (__force __fs64)cpu_to_be64(n);
61566 }
61567
61568 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61569 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61570 {
61571 if (sbi->s_bytesex == BYTESEX_LE)
61572 return le32_to_cpu((__force __le32)n);
61573 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
61574 index 16e8abb..2dcf914 100644
61575 --- a/fs/quota/netlink.c
61576 +++ b/fs/quota/netlink.c
61577 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
61578 void quota_send_warning(struct kqid qid, dev_t dev,
61579 const char warntype)
61580 {
61581 - static atomic_t seq;
61582 + static atomic_unchecked_t seq;
61583 struct sk_buff *skb;
61584 void *msg_head;
61585 int ret;
61586 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
61587 "VFS: Not enough memory to send quota warning.\n");
61588 return;
61589 }
61590 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
61591 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
61592 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
61593 if (!msg_head) {
61594 printk(KERN_ERR
61595 diff --git a/fs/read_write.c b/fs/read_write.c
61596 index 2cefa41..c7e2fe0 100644
61597 --- a/fs/read_write.c
61598 +++ b/fs/read_write.c
61599 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
61600
61601 old_fs = get_fs();
61602 set_fs(get_ds());
61603 - p = (__force const char __user *)buf;
61604 + p = (const char __force_user *)buf;
61605 if (count > MAX_RW_COUNT)
61606 count = MAX_RW_COUNT;
61607 if (file->f_op->write)
61608 diff --git a/fs/readdir.c b/fs/readdir.c
61609 index fee38e0..12fdf47 100644
61610 --- a/fs/readdir.c
61611 +++ b/fs/readdir.c
61612 @@ -17,6 +17,7 @@
61613 #include <linux/security.h>
61614 #include <linux/syscalls.h>
61615 #include <linux/unistd.h>
61616 +#include <linux/namei.h>
61617
61618 #include <asm/uaccess.h>
61619
61620 @@ -67,6 +68,7 @@ struct old_linux_dirent {
61621
61622 struct readdir_callback {
61623 struct old_linux_dirent __user * dirent;
61624 + struct file * file;
61625 int result;
61626 };
61627
61628 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
61629 buf->result = -EOVERFLOW;
61630 return -EOVERFLOW;
61631 }
61632 +
61633 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61634 + return 0;
61635 +
61636 buf->result++;
61637 dirent = buf->dirent;
61638 if (!access_ok(VERIFY_WRITE, dirent,
61639 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
61640
61641 buf.result = 0;
61642 buf.dirent = dirent;
61643 + buf.file = f.file;
61644
61645 error = vfs_readdir(f.file, fillonedir, &buf);
61646 if (buf.result)
61647 @@ -139,6 +146,7 @@ struct linux_dirent {
61648 struct getdents_callback {
61649 struct linux_dirent __user * current_dir;
61650 struct linux_dirent __user * previous;
61651 + struct file * file;
61652 int count;
61653 int error;
61654 };
61655 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
61656 buf->error = -EOVERFLOW;
61657 return -EOVERFLOW;
61658 }
61659 +
61660 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61661 + return 0;
61662 +
61663 dirent = buf->previous;
61664 if (dirent) {
61665 if (__put_user(offset, &dirent->d_off))
61666 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61667 buf.previous = NULL;
61668 buf.count = count;
61669 buf.error = 0;
61670 + buf.file = f.file;
61671
61672 error = vfs_readdir(f.file, filldir, &buf);
61673 if (error >= 0)
61674 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61675 struct getdents_callback64 {
61676 struct linux_dirent64 __user * current_dir;
61677 struct linux_dirent64 __user * previous;
61678 + struct file *file;
61679 int count;
61680 int error;
61681 };
61682 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
61683 buf->error = -EINVAL; /* only used if we fail.. */
61684 if (reclen > buf->count)
61685 return -EINVAL;
61686 +
61687 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61688 + return 0;
61689 +
61690 dirent = buf->previous;
61691 if (dirent) {
61692 if (__put_user(offset, &dirent->d_off))
61693 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61694
61695 buf.current_dir = dirent;
61696 buf.previous = NULL;
61697 + buf.file = f.file;
61698 buf.count = count;
61699 buf.error = 0;
61700
61701 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61702 error = buf.error;
61703 lastdirent = buf.previous;
61704 if (lastdirent) {
61705 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
61706 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
61707 if (__put_user(d_off, &lastdirent->d_off))
61708 error = -EFAULT;
61709 else
61710 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
61711 index 2b7882b..1c5ef48 100644
61712 --- a/fs/reiserfs/do_balan.c
61713 +++ b/fs/reiserfs/do_balan.c
61714 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
61715 return;
61716 }
61717
61718 - atomic_inc(&(fs_generation(tb->tb_sb)));
61719 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
61720 do_balance_starts(tb);
61721
61722 /* balance leaf returns 0 except if combining L R and S into
61723 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
61724 index 1d48974..2f8f4e0 100644
61725 --- a/fs/reiserfs/procfs.c
61726 +++ b/fs/reiserfs/procfs.c
61727 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61728 "SMALL_TAILS " : "NO_TAILS ",
61729 replay_only(sb) ? "REPLAY_ONLY " : "",
61730 convert_reiserfs(sb) ? "CONV " : "",
61731 - atomic_read(&r->s_generation_counter),
61732 + atomic_read_unchecked(&r->s_generation_counter),
61733 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61734 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61735 SF(s_good_search_by_key_reada), SF(s_bmaps),
61736 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
61737 index 157e474..65a6114 100644
61738 --- a/fs/reiserfs/reiserfs.h
61739 +++ b/fs/reiserfs/reiserfs.h
61740 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
61741 /* Comment? -Hans */
61742 wait_queue_head_t s_wait;
61743 /* To be obsoleted soon by per buffer seals.. -Hans */
61744 - atomic_t s_generation_counter; // increased by one every time the
61745 + atomic_unchecked_t s_generation_counter; // increased by one every time the
61746 // tree gets re-balanced
61747 unsigned long s_properties; /* File system properties. Currently holds
61748 on-disk FS format */
61749 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
61750 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
61751
61752 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
61753 -#define get_generation(s) atomic_read (&fs_generation(s))
61754 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
61755 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
61756 #define __fs_changed(gen,s) (gen != get_generation (s))
61757 #define fs_changed(gen,s) \
61758 diff --git a/fs/select.c b/fs/select.c
61759 index 8c1c96c..a0f9b6d 100644
61760 --- a/fs/select.c
61761 +++ b/fs/select.c
61762 @@ -20,6 +20,7 @@
61763 #include <linux/export.h>
61764 #include <linux/slab.h>
61765 #include <linux/poll.h>
61766 +#include <linux/security.h>
61767 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
61768 #include <linux/file.h>
61769 #include <linux/fdtable.h>
61770 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
61771 struct poll_list *walk = head;
61772 unsigned long todo = nfds;
61773
61774 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
61775 if (nfds > rlimit(RLIMIT_NOFILE))
61776 return -EINVAL;
61777
61778 diff --git a/fs/seq_file.c b/fs/seq_file.c
61779 index 774c1eb..b67582a 100644
61780 --- a/fs/seq_file.c
61781 +++ b/fs/seq_file.c
61782 @@ -10,6 +10,7 @@
61783 #include <linux/seq_file.h>
61784 #include <linux/slab.h>
61785 #include <linux/cred.h>
61786 +#include <linux/sched.h>
61787
61788 #include <asm/uaccess.h>
61789 #include <asm/page.h>
61790 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
61791 #ifdef CONFIG_USER_NS
61792 p->user_ns = file->f_cred->user_ns;
61793 #endif
61794 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61795 + p->exec_id = current->exec_id;
61796 +#endif
61797
61798 /*
61799 * Wrappers around seq_open(e.g. swaps_open) need to be
61800 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61801 return 0;
61802 }
61803 if (!m->buf) {
61804 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61805 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61806 if (!m->buf)
61807 return -ENOMEM;
61808 }
61809 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61810 Eoverflow:
61811 m->op->stop(m, p);
61812 kfree(m->buf);
61813 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61814 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61815 return !m->buf ? -ENOMEM : -EAGAIN;
61816 }
61817
61818 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61819
61820 /* grab buffer if we didn't have one */
61821 if (!m->buf) {
61822 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61823 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61824 if (!m->buf)
61825 goto Enomem;
61826 }
61827 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61828 goto Fill;
61829 m->op->stop(m, p);
61830 kfree(m->buf);
61831 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61832 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61833 if (!m->buf)
61834 goto Enomem;
61835 m->count = 0;
61836 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
61837 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61838 void *data)
61839 {
61840 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61841 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61842 int res = -ENOMEM;
61843
61844 if (op) {
61845 diff --git a/fs/splice.c b/fs/splice.c
61846 index d37431d..81c3044 100644
61847 --- a/fs/splice.c
61848 +++ b/fs/splice.c
61849 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61850 pipe_lock(pipe);
61851
61852 for (;;) {
61853 - if (!pipe->readers) {
61854 + if (!atomic_read(&pipe->readers)) {
61855 send_sig(SIGPIPE, current, 0);
61856 if (!ret)
61857 ret = -EPIPE;
61858 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61859 page_nr++;
61860 ret += buf->len;
61861
61862 - if (pipe->files)
61863 + if (atomic_read(&pipe->files))
61864 do_wakeup = 1;
61865
61866 if (!--spd->nr_pages)
61867 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61868 do_wakeup = 0;
61869 }
61870
61871 - pipe->waiting_writers++;
61872 + atomic_inc(&pipe->waiting_writers);
61873 pipe_wait(pipe);
61874 - pipe->waiting_writers--;
61875 + atomic_dec(&pipe->waiting_writers);
61876 }
61877
61878 pipe_unlock(pipe);
61879 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61880 old_fs = get_fs();
61881 set_fs(get_ds());
61882 /* The cast to a user pointer is valid due to the set_fs() */
61883 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61884 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61885 set_fs(old_fs);
61886
61887 return res;
61888 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61889 old_fs = get_fs();
61890 set_fs(get_ds());
61891 /* The cast to a user pointer is valid due to the set_fs() */
61892 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61893 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61894 set_fs(old_fs);
61895
61896 return res;
61897 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61898 goto err;
61899
61900 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61901 - vec[i].iov_base = (void __user *) page_address(page);
61902 + vec[i].iov_base = (void __force_user *) page_address(page);
61903 vec[i].iov_len = this_len;
61904 spd.pages[i] = page;
61905 spd.nr_pages++;
61906 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61907 ops->release(pipe, buf);
61908 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61909 pipe->nrbufs--;
61910 - if (pipe->files)
61911 + if (atomic_read(&pipe->files))
61912 sd->need_wakeup = true;
61913 }
61914
61915 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61916 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61917 {
61918 while (!pipe->nrbufs) {
61919 - if (!pipe->writers)
61920 + if (!atomic_read(&pipe->writers))
61921 return 0;
61922
61923 - if (!pipe->waiting_writers && sd->num_spliced)
61924 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61925 return 0;
61926
61927 if (sd->flags & SPLICE_F_NONBLOCK)
61928 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61929 * out of the pipe right after the splice_to_pipe(). So set
61930 * PIPE_READERS appropriately.
61931 */
61932 - pipe->readers = 1;
61933 + atomic_set(&pipe->readers, 1);
61934
61935 current->splice_pipe = pipe;
61936 }
61937 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61938 ret = -ERESTARTSYS;
61939 break;
61940 }
61941 - if (!pipe->writers)
61942 + if (!atomic_read(&pipe->writers))
61943 break;
61944 - if (!pipe->waiting_writers) {
61945 + if (!atomic_read(&pipe->waiting_writers)) {
61946 if (flags & SPLICE_F_NONBLOCK) {
61947 ret = -EAGAIN;
61948 break;
61949 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61950 pipe_lock(pipe);
61951
61952 while (pipe->nrbufs >= pipe->buffers) {
61953 - if (!pipe->readers) {
61954 + if (!atomic_read(&pipe->readers)) {
61955 send_sig(SIGPIPE, current, 0);
61956 ret = -EPIPE;
61957 break;
61958 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61959 ret = -ERESTARTSYS;
61960 break;
61961 }
61962 - pipe->waiting_writers++;
61963 + atomic_inc(&pipe->waiting_writers);
61964 pipe_wait(pipe);
61965 - pipe->waiting_writers--;
61966 + atomic_dec(&pipe->waiting_writers);
61967 }
61968
61969 pipe_unlock(pipe);
61970 @@ -1854,14 +1854,14 @@ retry:
61971 pipe_double_lock(ipipe, opipe);
61972
61973 do {
61974 - if (!opipe->readers) {
61975 + if (!atomic_read(&opipe->readers)) {
61976 send_sig(SIGPIPE, current, 0);
61977 if (!ret)
61978 ret = -EPIPE;
61979 break;
61980 }
61981
61982 - if (!ipipe->nrbufs && !ipipe->writers)
61983 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61984 break;
61985
61986 /*
61987 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61988 pipe_double_lock(ipipe, opipe);
61989
61990 do {
61991 - if (!opipe->readers) {
61992 + if (!atomic_read(&opipe->readers)) {
61993 send_sig(SIGPIPE, current, 0);
61994 if (!ret)
61995 ret = -EPIPE;
61996 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61997 * return EAGAIN if we have the potential of some data in the
61998 * future, otherwise just return 0
61999 */
62000 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
62001 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
62002 ret = -EAGAIN;
62003
62004 pipe_unlock(ipipe);
62005 diff --git a/fs/stat.c b/fs/stat.c
62006 index 04ce1ac..a13dd1e 100644
62007 --- a/fs/stat.c
62008 +++ b/fs/stat.c
62009 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
62010 stat->gid = inode->i_gid;
62011 stat->rdev = inode->i_rdev;
62012 stat->size = i_size_read(inode);
62013 - stat->atime = inode->i_atime;
62014 - stat->mtime = inode->i_mtime;
62015 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62016 + stat->atime = inode->i_ctime;
62017 + stat->mtime = inode->i_ctime;
62018 + } else {
62019 + stat->atime = inode->i_atime;
62020 + stat->mtime = inode->i_mtime;
62021 + }
62022 stat->ctime = inode->i_ctime;
62023 stat->blksize = (1 << inode->i_blkbits);
62024 stat->blocks = inode->i_blocks;
62025 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
62026 if (retval)
62027 return retval;
62028
62029 - if (inode->i_op->getattr)
62030 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
62031 + if (inode->i_op->getattr) {
62032 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
62033 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62034 + stat->atime = stat->ctime;
62035 + stat->mtime = stat->ctime;
62036 + }
62037 + return retval;
62038 + }
62039
62040 generic_fillattr(inode, stat);
62041 return 0;
62042 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
62043 index 15c68f9..36a8b3e 100644
62044 --- a/fs/sysfs/bin.c
62045 +++ b/fs/sysfs/bin.c
62046 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
62047 return ret;
62048 }
62049
62050 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
62051 - void *buf, int len, int write)
62052 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
62053 + void *buf, size_t len, int write)
62054 {
62055 struct file *file = vma->vm_file;
62056 struct bin_buffer *bb = file->private_data;
62057 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
62058 - int ret;
62059 + ssize_t ret;
62060
62061 if (!bb->vm_ops)
62062 return -EINVAL;
62063 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
62064 index e8e0e71..79c28ac5 100644
62065 --- a/fs/sysfs/dir.c
62066 +++ b/fs/sysfs/dir.c
62067 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
62068 *
62069 * Returns 31 bit hash of ns + name (so it fits in an off_t )
62070 */
62071 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
62072 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
62073 {
62074 unsigned long hash = init_name_hash();
62075 unsigned int len = strlen(name);
62076 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
62077 struct sysfs_dirent *sd;
62078 int rc;
62079
62080 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
62081 + const char *parent_name = parent_sd->s_name;
62082 +
62083 + mode = S_IFDIR | S_IRWXU;
62084 +
62085 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
62086 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
62087 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
62088 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
62089 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
62090 +#endif
62091 +
62092 /* allocate */
62093 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
62094 if (!sd)
62095 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
62096 index 602f56d..6853db8 100644
62097 --- a/fs/sysfs/file.c
62098 +++ b/fs/sysfs/file.c
62099 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
62100
62101 struct sysfs_open_dirent {
62102 atomic_t refcnt;
62103 - atomic_t event;
62104 + atomic_unchecked_t event;
62105 wait_queue_head_t poll;
62106 struct list_head buffers; /* goes through sysfs_buffer.list */
62107 };
62108 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
62109 if (!sysfs_get_active(attr_sd))
62110 return -ENODEV;
62111
62112 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
62113 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
62114 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
62115
62116 sysfs_put_active(attr_sd);
62117 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
62118 return -ENOMEM;
62119
62120 atomic_set(&new_od->refcnt, 0);
62121 - atomic_set(&new_od->event, 1);
62122 + atomic_set_unchecked(&new_od->event, 1);
62123 init_waitqueue_head(&new_od->poll);
62124 INIT_LIST_HEAD(&new_od->buffers);
62125 goto retry;
62126 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
62127
62128 sysfs_put_active(attr_sd);
62129
62130 - if (buffer->event != atomic_read(&od->event))
62131 + if (buffer->event != atomic_read_unchecked(&od->event))
62132 goto trigger;
62133
62134 return DEFAULT_POLLMASK;
62135 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
62136
62137 od = sd->s_attr.open;
62138 if (od) {
62139 - atomic_inc(&od->event);
62140 + atomic_inc_unchecked(&od->event);
62141 wake_up_interruptible(&od->poll);
62142 }
62143
62144 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
62145 index 8c940df..25b733e 100644
62146 --- a/fs/sysfs/symlink.c
62147 +++ b/fs/sysfs/symlink.c
62148 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
62149
62150 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
62151 {
62152 - char *page = nd_get_link(nd);
62153 + const char *page = nd_get_link(nd);
62154 if (!IS_ERR(page))
62155 free_page((unsigned long)page);
62156 }
62157 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
62158 index 69d4889..a810bd4 100644
62159 --- a/fs/sysv/sysv.h
62160 +++ b/fs/sysv/sysv.h
62161 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
62162 #endif
62163 }
62164
62165 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62166 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62167 {
62168 if (sbi->s_bytesex == BYTESEX_PDP)
62169 return PDP_swab((__force __u32)n);
62170 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
62171 index e18b988..f1d4ad0f 100644
62172 --- a/fs/ubifs/io.c
62173 +++ b/fs/ubifs/io.c
62174 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
62175 return err;
62176 }
62177
62178 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62179 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62180 {
62181 int err;
62182
62183 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
62184 index c175b4d..8f36a16 100644
62185 --- a/fs/udf/misc.c
62186 +++ b/fs/udf/misc.c
62187 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
62188
62189 u8 udf_tag_checksum(const struct tag *t)
62190 {
62191 - u8 *data = (u8 *)t;
62192 + const u8 *data = (const u8 *)t;
62193 u8 checksum = 0;
62194 int i;
62195 for (i = 0; i < sizeof(struct tag); ++i)
62196 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
62197 index 8d974c4..b82f6ec 100644
62198 --- a/fs/ufs/swab.h
62199 +++ b/fs/ufs/swab.h
62200 @@ -22,7 +22,7 @@ enum {
62201 BYTESEX_BE
62202 };
62203
62204 -static inline u64
62205 +static inline u64 __intentional_overflow(-1)
62206 fs64_to_cpu(struct super_block *sbp, __fs64 n)
62207 {
62208 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62209 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
62210 return (__force __fs64)cpu_to_be64(n);
62211 }
62212
62213 -static inline u32
62214 +static inline u32 __intentional_overflow(-1)
62215 fs32_to_cpu(struct super_block *sbp, __fs32 n)
62216 {
62217 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62218 diff --git a/fs/utimes.c b/fs/utimes.c
62219 index f4fb7ec..3fe03c0 100644
62220 --- a/fs/utimes.c
62221 +++ b/fs/utimes.c
62222 @@ -1,6 +1,7 @@
62223 #include <linux/compiler.h>
62224 #include <linux/file.h>
62225 #include <linux/fs.h>
62226 +#include <linux/security.h>
62227 #include <linux/linkage.h>
62228 #include <linux/mount.h>
62229 #include <linux/namei.h>
62230 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
62231 goto mnt_drop_write_and_out;
62232 }
62233 }
62234 +
62235 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
62236 + error = -EACCES;
62237 + goto mnt_drop_write_and_out;
62238 + }
62239 +
62240 mutex_lock(&inode->i_mutex);
62241 error = notify_change(path->dentry, &newattrs);
62242 mutex_unlock(&inode->i_mutex);
62243 diff --git a/fs/xattr.c b/fs/xattr.c
62244 index 3377dff..4d074d9 100644
62245 --- a/fs/xattr.c
62246 +++ b/fs/xattr.c
62247 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
62248 return rc;
62249 }
62250
62251 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
62252 +ssize_t
62253 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
62254 +{
62255 + struct inode *inode = dentry->d_inode;
62256 + ssize_t error;
62257 +
62258 + error = inode_permission(inode, MAY_EXEC);
62259 + if (error)
62260 + return error;
62261 +
62262 + if (inode->i_op->getxattr)
62263 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
62264 + else
62265 + error = -EOPNOTSUPP;
62266 +
62267 + return error;
62268 +}
62269 +EXPORT_SYMBOL(pax_getxattr);
62270 +#endif
62271 +
62272 ssize_t
62273 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
62274 {
62275 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
62276 * Extended attribute SET operations
62277 */
62278 static long
62279 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
62280 +setxattr(struct path *path, const char __user *name, const void __user *value,
62281 size_t size, int flags)
62282 {
62283 int error;
62284 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
62285 posix_acl_fix_xattr_from_user(kvalue, size);
62286 }
62287
62288 - error = vfs_setxattr(d, kname, kvalue, size, flags);
62289 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
62290 + error = -EACCES;
62291 + goto out;
62292 + }
62293 +
62294 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
62295 out:
62296 if (vvalue)
62297 vfree(vvalue);
62298 @@ -377,7 +403,7 @@ retry:
62299 return error;
62300 error = mnt_want_write(path.mnt);
62301 if (!error) {
62302 - error = setxattr(path.dentry, name, value, size, flags);
62303 + error = setxattr(&path, name, value, size, flags);
62304 mnt_drop_write(path.mnt);
62305 }
62306 path_put(&path);
62307 @@ -401,7 +427,7 @@ retry:
62308 return error;
62309 error = mnt_want_write(path.mnt);
62310 if (!error) {
62311 - error = setxattr(path.dentry, name, value, size, flags);
62312 + error = setxattr(&path, name, value, size, flags);
62313 mnt_drop_write(path.mnt);
62314 }
62315 path_put(&path);
62316 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
62317 const void __user *,value, size_t, size, int, flags)
62318 {
62319 struct fd f = fdget(fd);
62320 - struct dentry *dentry;
62321 int error = -EBADF;
62322
62323 if (!f.file)
62324 return error;
62325 - dentry = f.file->f_path.dentry;
62326 - audit_inode(NULL, dentry, 0);
62327 + audit_inode(NULL, f.file->f_path.dentry, 0);
62328 error = mnt_want_write_file(f.file);
62329 if (!error) {
62330 - error = setxattr(dentry, name, value, size, flags);
62331 + error = setxattr(&f.file->f_path, name, value, size, flags);
62332 mnt_drop_write_file(f.file);
62333 }
62334 fdput(f);
62335 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
62336 index 9fbea87..6b19972 100644
62337 --- a/fs/xattr_acl.c
62338 +++ b/fs/xattr_acl.c
62339 @@ -76,8 +76,8 @@ struct posix_acl *
62340 posix_acl_from_xattr(struct user_namespace *user_ns,
62341 const void *value, size_t size)
62342 {
62343 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62344 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62345 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62346 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62347 int count;
62348 struct posix_acl *acl;
62349 struct posix_acl_entry *acl_e;
62350 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
62351 index 8904284..ee0e14b 100644
62352 --- a/fs/xfs/xfs_bmap.c
62353 +++ b/fs/xfs/xfs_bmap.c
62354 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
62355
62356 #else
62357 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
62358 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
62359 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
62360 #endif /* DEBUG */
62361
62362 /*
62363 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
62364 index 6157424..ac98f6d 100644
62365 --- a/fs/xfs/xfs_dir2_sf.c
62366 +++ b/fs/xfs/xfs_dir2_sf.c
62367 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
62368 }
62369
62370 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
62371 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
62372 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
62373 + char name[sfep->namelen];
62374 + memcpy(name, sfep->name, sfep->namelen);
62375 + if (filldir(dirent, name, sfep->namelen,
62376 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
62377 + *offset = off & 0x7fffffff;
62378 + return 0;
62379 + }
62380 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
62381 off & 0x7fffffff, ino, DT_UNKNOWN)) {
62382 *offset = off & 0x7fffffff;
62383 return 0;
62384 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
62385 index 5e99968..45bd327 100644
62386 --- a/fs/xfs/xfs_ioctl.c
62387 +++ b/fs/xfs/xfs_ioctl.c
62388 @@ -127,7 +127,7 @@ xfs_find_handle(
62389 }
62390
62391 error = -EFAULT;
62392 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
62393 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
62394 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
62395 goto out_put;
62396
62397 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
62398 index ca9ecaa..60100c7 100644
62399 --- a/fs/xfs/xfs_iops.c
62400 +++ b/fs/xfs/xfs_iops.c
62401 @@ -395,7 +395,7 @@ xfs_vn_put_link(
62402 struct nameidata *nd,
62403 void *p)
62404 {
62405 - char *s = nd_get_link(nd);
62406 + const char *s = nd_get_link(nd);
62407
62408 if (!IS_ERR(s))
62409 kfree(s);
62410 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
62411 new file mode 100644
62412 index 0000000..6fb5192
62413 --- /dev/null
62414 +++ b/grsecurity/Kconfig
62415 @@ -0,0 +1,1079 @@
62416 +#
62417 +# grecurity configuration
62418 +#
62419 +menu "Memory Protections"
62420 +depends on GRKERNSEC
62421 +
62422 +config GRKERNSEC_KMEM
62423 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
62424 + default y if GRKERNSEC_CONFIG_AUTO
62425 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
62426 + help
62427 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
62428 + be written to or read from to modify or leak the contents of the running
62429 + kernel. /dev/port will also not be allowed to be opened and support
62430 + for /dev/cpu/*/msr will be removed. If you have module
62431 + support disabled, enabling this will close up five ways that are
62432 + currently used to insert malicious code into the running kernel.
62433 +
62434 + Even with all these features enabled, we still highly recommend that
62435 + you use the RBAC system, as it is still possible for an attacker to
62436 + modify the running kernel through privileged I/O granted by ioperm/iopl.
62437 +
62438 + If you are not using XFree86, you may be able to stop this additional
62439 + case by enabling the 'Disable privileged I/O' option. Though nothing
62440 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
62441 + but only to video memory, which is the only writing we allow in this
62442 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
62443 + not be allowed to mprotect it with PROT_WRITE later.
62444 + Enabling this feature will prevent the "cpupower" and "powertop" tools
62445 + from working.
62446 +
62447 + It is highly recommended that you say Y here if you meet all the
62448 + conditions above.
62449 +
62450 +config GRKERNSEC_VM86
62451 + bool "Restrict VM86 mode"
62452 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62453 + depends on X86_32
62454 +
62455 + help
62456 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
62457 + make use of a special execution mode on 32bit x86 processors called
62458 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
62459 + video cards and will still work with this option enabled. The purpose
62460 + of the option is to prevent exploitation of emulation errors in
62461 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
62462 + Nearly all users should be able to enable this option.
62463 +
62464 +config GRKERNSEC_IO
62465 + bool "Disable privileged I/O"
62466 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62467 + depends on X86
62468 + select RTC_CLASS
62469 + select RTC_INTF_DEV
62470 + select RTC_DRV_CMOS
62471 +
62472 + help
62473 + If you say Y here, all ioperm and iopl calls will return an error.
62474 + Ioperm and iopl can be used to modify the running kernel.
62475 + Unfortunately, some programs need this access to operate properly,
62476 + the most notable of which are XFree86 and hwclock. hwclock can be
62477 + remedied by having RTC support in the kernel, so real-time
62478 + clock support is enabled if this option is enabled, to ensure
62479 + that hwclock operates correctly. XFree86 still will not
62480 + operate correctly with this option enabled, so DO NOT CHOOSE Y
62481 + IF YOU USE XFree86. If you use XFree86 and you still want to
62482 + protect your kernel against modification, use the RBAC system.
62483 +
62484 +config GRKERNSEC_JIT_HARDEN
62485 + bool "Harden BPF JIT against spray attacks"
62486 + default y if GRKERNSEC_CONFIG_AUTO
62487 + depends on BPF_JIT
62488 + help
62489 + If you say Y here, the native code generated by the kernel's Berkeley
62490 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
62491 + attacks that attempt to fit attacker-beneficial instructions in
62492 + 32bit immediate fields of JIT-generated native instructions. The
62493 + attacker will generally aim to cause an unintended instruction sequence
62494 + of JIT-generated native code to execute by jumping into the middle of
62495 + a generated instruction. This feature effectively randomizes the 32bit
62496 + immediate constants present in the generated code to thwart such attacks.
62497 +
62498 + If you're using KERNEXEC, it's recommended that you enable this option
62499 + to supplement the hardening of the kernel.
62500 +
62501 +config GRKERNSEC_PERF_HARDEN
62502 + bool "Disable unprivileged PERF_EVENTS usage by default"
62503 + default y if GRKERNSEC_CONFIG_AUTO
62504 + depends on PERF_EVENTS
62505 + help
62506 + If you say Y here, the range of acceptable values for the
62507 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
62508 + default to a new value: 3. When the sysctl is set to this value, no
62509 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
62510 +
62511 + Though PERF_EVENTS can be used legitimately for performance monitoring
62512 + and low-level application profiling, it is forced on regardless of
62513 + configuration, has been at fault for several vulnerabilities, and
62514 + creates new opportunities for side channels and other information leaks.
62515 +
62516 + This feature puts PERF_EVENTS into a secure default state and permits
62517 + the administrator to change out of it temporarily if unprivileged
62518 + application profiling is needed.
62519 +
62520 +config GRKERNSEC_RAND_THREADSTACK
62521 + bool "Insert random gaps between thread stacks"
62522 + default y if GRKERNSEC_CONFIG_AUTO
62523 + depends on PAX_RANDMMAP && !PPC
62524 + help
62525 + If you say Y here, a random-sized gap will be enforced between allocated
62526 + thread stacks. Glibc's NPTL and other threading libraries that
62527 + pass MAP_STACK to the kernel for thread stack allocation are supported.
62528 + The implementation currently provides 8 bits of entropy for the gap.
62529 +
62530 + Many distributions do not compile threaded remote services with the
62531 + -fstack-check argument to GCC, causing the variable-sized stack-based
62532 + allocator, alloca(), to not probe the stack on allocation. This
62533 + permits an unbounded alloca() to skip over any guard page and potentially
62534 + modify another thread's stack reliably. An enforced random gap
62535 + reduces the reliability of such an attack and increases the chance
62536 + that such a read/write to another thread's stack instead lands in
62537 + an unmapped area, causing a crash and triggering grsecurity's
62538 + anti-bruteforcing logic.
62539 +
62540 +config GRKERNSEC_PROC_MEMMAP
62541 + bool "Harden ASLR against information leaks and entropy reduction"
62542 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
62543 + depends on PAX_NOEXEC || PAX_ASLR
62544 + help
62545 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
62546 + give no information about the addresses of its mappings if
62547 + PaX features that rely on random addresses are enabled on the task.
62548 + In addition to sanitizing this information and disabling other
62549 + dangerous sources of information, this option causes reads of sensitive
62550 + /proc/<pid> entries where the file descriptor was opened in a different
62551 + task than the one performing the read. Such attempts are logged.
62552 + This option also limits argv/env strings for suid/sgid binaries
62553 + to 512KB to prevent a complete exhaustion of the stack entropy provided
62554 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
62555 + binaries to prevent alternative mmap layouts from being abused.
62556 +
62557 + If you use PaX it is essential that you say Y here as it closes up
62558 + several holes that make full ASLR useless locally.
62559 +
62560 +config GRKERNSEC_BRUTE
62561 + bool "Deter exploit bruteforcing"
62562 + default y if GRKERNSEC_CONFIG_AUTO
62563 + help
62564 + If you say Y here, attempts to bruteforce exploits against forking
62565 + daemons such as apache or sshd, as well as against suid/sgid binaries
62566 + will be deterred. When a child of a forking daemon is killed by PaX
62567 + or crashes due to an illegal instruction or other suspicious signal,
62568 + the parent process will be delayed 30 seconds upon every subsequent
62569 + fork until the administrator is able to assess the situation and
62570 + restart the daemon.
62571 + In the suid/sgid case, the attempt is logged, the user has all their
62572 + existing instances of the suid/sgid binary terminated and will
62573 + be unable to execute any suid/sgid binaries for 15 minutes.
62574 +
62575 + It is recommended that you also enable signal logging in the auditing
62576 + section so that logs are generated when a process triggers a suspicious
62577 + signal.
62578 + If the sysctl option is enabled, a sysctl option with name
62579 + "deter_bruteforce" is created.
62580 +
62581 +
62582 +config GRKERNSEC_MODHARDEN
62583 + bool "Harden module auto-loading"
62584 + default y if GRKERNSEC_CONFIG_AUTO
62585 + depends on MODULES
62586 + help
62587 + If you say Y here, module auto-loading in response to use of some
62588 + feature implemented by an unloaded module will be restricted to
62589 + root users. Enabling this option helps defend against attacks
62590 + by unprivileged users who abuse the auto-loading behavior to
62591 + cause a vulnerable module to load that is then exploited.
62592 +
62593 + If this option prevents a legitimate use of auto-loading for a
62594 + non-root user, the administrator can execute modprobe manually
62595 + with the exact name of the module mentioned in the alert log.
62596 + Alternatively, the administrator can add the module to the list
62597 + of modules loaded at boot by modifying init scripts.
62598 +
62599 + Modification of init scripts will most likely be needed on
62600 + Ubuntu servers with encrypted home directory support enabled,
62601 + as the first non-root user logging in will cause the ecb(aes),
62602 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
62603 +
62604 +config GRKERNSEC_HIDESYM
62605 + bool "Hide kernel symbols"
62606 + default y if GRKERNSEC_CONFIG_AUTO
62607 + select PAX_USERCOPY_SLABS
62608 + help
62609 + If you say Y here, getting information on loaded modules, and
62610 + displaying all kernel symbols through a syscall will be restricted
62611 + to users with CAP_SYS_MODULE. For software compatibility reasons,
62612 + /proc/kallsyms will be restricted to the root user. The RBAC
62613 + system can hide that entry even from root.
62614 +
62615 + This option also prevents leaking of kernel addresses through
62616 + several /proc entries.
62617 +
62618 + Note that this option is only effective provided the following
62619 + conditions are met:
62620 + 1) The kernel using grsecurity is not precompiled by some distribution
62621 + 2) You have also enabled GRKERNSEC_DMESG
62622 + 3) You are using the RBAC system and hiding other files such as your
62623 + kernel image and System.map. Alternatively, enabling this option
62624 + causes the permissions on /boot, /lib/modules, and the kernel
62625 + source directory to change at compile time to prevent
62626 + reading by non-root users.
62627 + If the above conditions are met, this option will aid in providing a
62628 + useful protection against local kernel exploitation of overflows
62629 + and arbitrary read/write vulnerabilities.
62630 +
62631 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
62632 + in addition to this feature.
62633 +
62634 +config GRKERNSEC_KERN_LOCKOUT
62635 + bool "Active kernel exploit response"
62636 + default y if GRKERNSEC_CONFIG_AUTO
62637 + depends on X86 || ARM || PPC || SPARC
62638 + help
62639 + If you say Y here, when a PaX alert is triggered due to suspicious
62640 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
62641 + or an OOPS occurs due to bad memory accesses, instead of just
62642 + terminating the offending process (and potentially allowing
62643 + a subsequent exploit from the same user), we will take one of two
62644 + actions:
62645 + If the user was root, we will panic the system
62646 + If the user was non-root, we will log the attempt, terminate
62647 + all processes owned by the user, then prevent them from creating
62648 + any new processes until the system is restarted
62649 + This deters repeated kernel exploitation/bruteforcing attempts
62650 + and is useful for later forensics.
62651 +
62652 +endmenu
62653 +menu "Role Based Access Control Options"
62654 +depends on GRKERNSEC
62655 +
62656 +config GRKERNSEC_RBAC_DEBUG
62657 + bool
62658 +
62659 +config GRKERNSEC_NO_RBAC
62660 + bool "Disable RBAC system"
62661 + help
62662 + If you say Y here, the /dev/grsec device will be removed from the kernel,
62663 + preventing the RBAC system from being enabled. You should only say Y
62664 + here if you have no intention of using the RBAC system, so as to prevent
62665 + an attacker with root access from misusing the RBAC system to hide files
62666 + and processes when loadable module support and /dev/[k]mem have been
62667 + locked down.
62668 +
62669 +config GRKERNSEC_ACL_HIDEKERN
62670 + bool "Hide kernel processes"
62671 + help
62672 + If you say Y here, all kernel threads will be hidden to all
62673 + processes but those whose subject has the "view hidden processes"
62674 + flag.
62675 +
62676 +config GRKERNSEC_ACL_MAXTRIES
62677 + int "Maximum tries before password lockout"
62678 + default 3
62679 + help
62680 + This option enforces the maximum number of times a user can attempt
62681 + to authorize themselves with the grsecurity RBAC system before being
62682 + denied the ability to attempt authorization again for a specified time.
62683 + The lower the number, the harder it will be to brute-force a password.
62684 +
62685 +config GRKERNSEC_ACL_TIMEOUT
62686 + int "Time to wait after max password tries, in seconds"
62687 + default 30
62688 + help
62689 + This option specifies the time the user must wait after attempting to
62690 + authorize to the RBAC system with the maximum number of invalid
62691 + passwords. The higher the number, the harder it will be to brute-force
62692 + a password.
62693 +
62694 +endmenu
62695 +menu "Filesystem Protections"
62696 +depends on GRKERNSEC
62697 +
62698 +config GRKERNSEC_PROC
62699 + bool "Proc restrictions"
62700 + default y if GRKERNSEC_CONFIG_AUTO
62701 + help
62702 + If you say Y here, the permissions of the /proc filesystem
62703 + will be altered to enhance system security and privacy. You MUST
62704 + choose either a user only restriction or a user and group restriction.
62705 + Depending upon the option you choose, you can either restrict users to
62706 + see only the processes they themselves run, or choose a group that can
62707 + view all processes and files normally restricted to root if you choose
62708 + the "restrict to user only" option. NOTE: If you're running identd or
62709 + ntpd as a non-root user, you will have to run it as the group you
62710 + specify here.
62711 +
62712 +config GRKERNSEC_PROC_USER
62713 + bool "Restrict /proc to user only"
62714 + depends on GRKERNSEC_PROC
62715 + help
62716 + If you say Y here, non-root users will only be able to view their own
62717 + processes, and restricts them from viewing network-related information,
62718 + and viewing kernel symbol and module information.
62719 +
62720 +config GRKERNSEC_PROC_USERGROUP
62721 + bool "Allow special group"
62722 + default y if GRKERNSEC_CONFIG_AUTO
62723 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
62724 + help
62725 + If you say Y here, you will be able to select a group that will be
62726 + able to view all processes and network-related information. If you've
62727 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
62728 + remain hidden. This option is useful if you want to run identd as
62729 + a non-root user. The group you select may also be chosen at boot time
62730 + via "grsec_proc_gid=" on the kernel commandline.
62731 +
62732 +config GRKERNSEC_PROC_GID
62733 + int "GID for special group"
62734 + depends on GRKERNSEC_PROC_USERGROUP
62735 + default 1001
62736 +
62737 +config GRKERNSEC_PROC_ADD
62738 + bool "Additional restrictions"
62739 + default y if GRKERNSEC_CONFIG_AUTO
62740 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
62741 + help
62742 + If you say Y here, additional restrictions will be placed on
62743 + /proc that keep normal users from viewing device information and
62744 + slabinfo information that could be useful for exploits.
62745 +
62746 +config GRKERNSEC_LINK
62747 + bool "Linking restrictions"
62748 + default y if GRKERNSEC_CONFIG_AUTO
62749 + help
62750 + If you say Y here, /tmp race exploits will be prevented, since users
62751 + will no longer be able to follow symlinks owned by other users in
62752 + world-writable +t directories (e.g. /tmp), unless the owner of the
62753 + symlink is the owner of the directory. users will also not be
62754 + able to hardlink to files they do not own. If the sysctl option is
62755 + enabled, a sysctl option with name "linking_restrictions" is created.
62756 +
62757 +config GRKERNSEC_SYMLINKOWN
62758 + bool "Kernel-enforced SymlinksIfOwnerMatch"
62759 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62760 + help
62761 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
62762 + that prevents it from being used as a security feature. As Apache
62763 + verifies the symlink by performing a stat() against the target of
62764 + the symlink before it is followed, an attacker can setup a symlink
62765 + to point to a same-owned file, then replace the symlink with one
62766 + that targets another user's file just after Apache "validates" the
62767 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
62768 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
62769 + will be in place for the group you specify. If the sysctl option
62770 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
62771 + created.
62772 +
62773 +config GRKERNSEC_SYMLINKOWN_GID
62774 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
62775 + depends on GRKERNSEC_SYMLINKOWN
62776 + default 1006
62777 + help
62778 + Setting this GID determines what group kernel-enforced
62779 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
62780 + is enabled, a sysctl option with name "symlinkown_gid" is created.
62781 +
62782 +config GRKERNSEC_FIFO
62783 + bool "FIFO restrictions"
62784 + default y if GRKERNSEC_CONFIG_AUTO
62785 + help
62786 + If you say Y here, users will not be able to write to FIFOs they don't
62787 + own in world-writable +t directories (e.g. /tmp), unless the owner of
62788 + the FIFO is the same owner of the directory it's held in. If the sysctl
62789 + option is enabled, a sysctl option with name "fifo_restrictions" is
62790 + created.
62791 +
62792 +config GRKERNSEC_SYSFS_RESTRICT
62793 + bool "Sysfs/debugfs restriction"
62794 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62795 + depends on SYSFS
62796 + help
62797 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
62798 + any filesystem normally mounted under it (e.g. debugfs) will be
62799 + mostly accessible only by root. These filesystems generally provide access
62800 + to hardware and debug information that isn't appropriate for unprivileged
62801 + users of the system. Sysfs and debugfs have also become a large source
62802 + of new vulnerabilities, ranging from infoleaks to local compromise.
62803 + There has been very little oversight with an eye toward security involved
62804 + in adding new exporters of information to these filesystems, so their
62805 + use is discouraged.
62806 + For reasons of compatibility, a few directories have been whitelisted
62807 + for access by non-root users:
62808 + /sys/fs/selinux
62809 + /sys/fs/fuse
62810 + /sys/devices/system/cpu
62811 +
62812 +config GRKERNSEC_ROFS
62813 + bool "Runtime read-only mount protection"
62814 + depends on SYSCTL
62815 + help
62816 + If you say Y here, a sysctl option with name "romount_protect" will
62817 + be created. By setting this option to 1 at runtime, filesystems
62818 + will be protected in the following ways:
62819 + * No new writable mounts will be allowed
62820 + * Existing read-only mounts won't be able to be remounted read/write
62821 + * Write operations will be denied on all block devices
62822 + This option acts independently of grsec_lock: once it is set to 1,
62823 + it cannot be turned off. Therefore, please be mindful of the resulting
62824 + behavior if this option is enabled in an init script on a read-only
62825 + filesystem. This feature is mainly intended for secure embedded systems.
62826 +
62827 +config GRKERNSEC_DEVICE_SIDECHANNEL
62828 + bool "Eliminate stat/notify-based device sidechannels"
62829 + default y if GRKERNSEC_CONFIG_AUTO
62830 + help
62831 + If you say Y here, timing analyses on block or character
62832 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62833 + will be thwarted for unprivileged users. If a process without
62834 + CAP_MKNOD stats such a device, the last access and last modify times
62835 + will match the device's create time. No access or modify events
62836 + will be triggered through inotify/dnotify/fanotify for such devices.
62837 + This feature will prevent attacks that may at a minimum
62838 + allow an attacker to determine the administrator's password length.
62839 +
62840 +config GRKERNSEC_CHROOT
62841 + bool "Chroot jail restrictions"
62842 + default y if GRKERNSEC_CONFIG_AUTO
62843 + help
62844 + If you say Y here, you will be able to choose several options that will
62845 + make breaking out of a chrooted jail much more difficult. If you
62846 + encounter no software incompatibilities with the following options, it
62847 + is recommended that you enable each one.
62848 +
62849 +config GRKERNSEC_CHROOT_MOUNT
62850 + bool "Deny mounts"
62851 + default y if GRKERNSEC_CONFIG_AUTO
62852 + depends on GRKERNSEC_CHROOT
62853 + help
62854 + If you say Y here, processes inside a chroot will not be able to
62855 + mount or remount filesystems. If the sysctl option is enabled, a
62856 + sysctl option with name "chroot_deny_mount" is created.
62857 +
62858 +config GRKERNSEC_CHROOT_DOUBLE
62859 + bool "Deny double-chroots"
62860 + default y if GRKERNSEC_CONFIG_AUTO
62861 + depends on GRKERNSEC_CHROOT
62862 + help
62863 + If you say Y here, processes inside a chroot will not be able to chroot
62864 + again outside the chroot. This is a widely used method of breaking
62865 + out of a chroot jail and should not be allowed. If the sysctl
62866 + option is enabled, a sysctl option with name
62867 + "chroot_deny_chroot" is created.
62868 +
62869 +config GRKERNSEC_CHROOT_PIVOT
62870 + bool "Deny pivot_root in chroot"
62871 + default y if GRKERNSEC_CONFIG_AUTO
62872 + depends on GRKERNSEC_CHROOT
62873 + help
62874 + If you say Y here, processes inside a chroot will not be able to use
62875 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62876 + works similar to chroot in that it changes the root filesystem. This
62877 + function could be misused in a chrooted process to attempt to break out
62878 + of the chroot, and therefore should not be allowed. If the sysctl
62879 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62880 + created.
62881 +
62882 +config GRKERNSEC_CHROOT_CHDIR
62883 + bool "Enforce chdir(\"/\") on all chroots"
62884 + default y if GRKERNSEC_CONFIG_AUTO
62885 + depends on GRKERNSEC_CHROOT
62886 + help
62887 + If you say Y here, the current working directory of all newly-chrooted
62888 + applications will be set to the the root directory of the chroot.
62889 + The man page on chroot(2) states:
62890 + Note that this call does not change the current working
62891 + directory, so that `.' can be outside the tree rooted at
62892 + `/'. In particular, the super-user can escape from a
62893 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62894 +
62895 + It is recommended that you say Y here, since it's not known to break
62896 + any software. If the sysctl option is enabled, a sysctl option with
62897 + name "chroot_enforce_chdir" is created.
62898 +
62899 +config GRKERNSEC_CHROOT_CHMOD
62900 + bool "Deny (f)chmod +s"
62901 + default y if GRKERNSEC_CONFIG_AUTO
62902 + depends on GRKERNSEC_CHROOT
62903 + help
62904 + If you say Y here, processes inside a chroot will not be able to chmod
62905 + or fchmod files to make them have suid or sgid bits. This protects
62906 + against another published method of breaking a chroot. If the sysctl
62907 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62908 + created.
62909 +
62910 +config GRKERNSEC_CHROOT_FCHDIR
62911 + bool "Deny fchdir out of chroot"
62912 + default y if GRKERNSEC_CONFIG_AUTO
62913 + depends on GRKERNSEC_CHROOT
62914 + help
62915 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62916 + to a file descriptor of the chrooting process that points to a directory
62917 + outside the filesystem will be stopped. If the sysctl option
62918 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62919 +
62920 +config GRKERNSEC_CHROOT_MKNOD
62921 + bool "Deny mknod"
62922 + default y if GRKERNSEC_CONFIG_AUTO
62923 + depends on GRKERNSEC_CHROOT
62924 + help
62925 + If you say Y here, processes inside a chroot will not be allowed to
62926 + mknod. The problem with using mknod inside a chroot is that it
62927 + would allow an attacker to create a device entry that is the same
62928 + as one on the physical root of your system, which could range from
62929 + anything from the console device to a device for your harddrive (which
62930 + they could then use to wipe the drive or steal data). It is recommended
62931 + that you say Y here, unless you run into software incompatibilities.
62932 + If the sysctl option is enabled, a sysctl option with name
62933 + "chroot_deny_mknod" is created.
62934 +
62935 +config GRKERNSEC_CHROOT_SHMAT
62936 + bool "Deny shmat() out of chroot"
62937 + default y if GRKERNSEC_CONFIG_AUTO
62938 + depends on GRKERNSEC_CHROOT
62939 + help
62940 + If you say Y here, processes inside a chroot will not be able to attach
62941 + to shared memory segments that were created outside of the chroot jail.
62942 + It is recommended that you say Y here. If the sysctl option is enabled,
62943 + a sysctl option with name "chroot_deny_shmat" is created.
62944 +
62945 +config GRKERNSEC_CHROOT_UNIX
62946 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62947 + default y if GRKERNSEC_CONFIG_AUTO
62948 + depends on GRKERNSEC_CHROOT
62949 + help
62950 + If you say Y here, processes inside a chroot will not be able to
62951 + connect to abstract (meaning not belonging to a filesystem) Unix
62952 + domain sockets that were bound outside of a chroot. It is recommended
62953 + that you say Y here. If the sysctl option is enabled, a sysctl option
62954 + with name "chroot_deny_unix" is created.
62955 +
62956 +config GRKERNSEC_CHROOT_FINDTASK
62957 + bool "Protect outside processes"
62958 + default y if GRKERNSEC_CONFIG_AUTO
62959 + depends on GRKERNSEC_CHROOT
62960 + help
62961 + If you say Y here, processes inside a chroot will not be able to
62962 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62963 + getsid, or view any process outside of the chroot. If the sysctl
62964 + option is enabled, a sysctl option with name "chroot_findtask" is
62965 + created.
62966 +
62967 +config GRKERNSEC_CHROOT_NICE
62968 + bool "Restrict priority changes"
62969 + default y if GRKERNSEC_CONFIG_AUTO
62970 + depends on GRKERNSEC_CHROOT
62971 + help
62972 + If you say Y here, processes inside a chroot will not be able to raise
62973 + the priority of processes in the chroot, or alter the priority of
62974 + processes outside the chroot. This provides more security than simply
62975 + removing CAP_SYS_NICE from the process' capability set. If the
62976 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62977 + is created.
62978 +
62979 +config GRKERNSEC_CHROOT_SYSCTL
62980 + bool "Deny sysctl writes"
62981 + default y if GRKERNSEC_CONFIG_AUTO
62982 + depends on GRKERNSEC_CHROOT
62983 + help
62984 + If you say Y here, an attacker in a chroot will not be able to
62985 + write to sysctl entries, either by sysctl(2) or through a /proc
62986 + interface. It is strongly recommended that you say Y here. If the
62987 + sysctl option is enabled, a sysctl option with name
62988 + "chroot_deny_sysctl" is created.
62989 +
62990 +config GRKERNSEC_CHROOT_CAPS
62991 + bool "Capability restrictions"
62992 + default y if GRKERNSEC_CONFIG_AUTO
62993 + depends on GRKERNSEC_CHROOT
62994 + help
62995 + If you say Y here, the capabilities on all processes within a
62996 + chroot jail will be lowered to stop module insertion, raw i/o,
62997 + system and net admin tasks, rebooting the system, modifying immutable
62998 + files, modifying IPC owned by another, and changing the system time.
62999 + This is left an option because it can break some apps. Disable this
63000 + if your chrooted apps are having problems performing those kinds of
63001 + tasks. If the sysctl option is enabled, a sysctl option with
63002 + name "chroot_caps" is created.
63003 +
63004 +config GRKERNSEC_CHROOT_INITRD
63005 + bool "Exempt initrd tasks from restrictions"
63006 + default y if GRKERNSEC_CONFIG_AUTO
63007 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
63008 + help
63009 + If you say Y here, tasks started prior to init will be exempted from
63010 + grsecurity's chroot restrictions. This option is mainly meant to
63011 + resolve Plymouth's performing privileged operations unnecessarily
63012 + in a chroot.
63013 +
63014 +endmenu
63015 +menu "Kernel Auditing"
63016 +depends on GRKERNSEC
63017 +
63018 +config GRKERNSEC_AUDIT_GROUP
63019 + bool "Single group for auditing"
63020 + help
63021 + If you say Y here, the exec and chdir logging features will only operate
63022 + on a group you specify. This option is recommended if you only want to
63023 + watch certain users instead of having a large amount of logs from the
63024 + entire system. If the sysctl option is enabled, a sysctl option with
63025 + name "audit_group" is created.
63026 +
63027 +config GRKERNSEC_AUDIT_GID
63028 + int "GID for auditing"
63029 + depends on GRKERNSEC_AUDIT_GROUP
63030 + default 1007
63031 +
63032 +config GRKERNSEC_EXECLOG
63033 + bool "Exec logging"
63034 + help
63035 + If you say Y here, all execve() calls will be logged (since the
63036 + other exec*() calls are frontends to execve(), all execution
63037 + will be logged). Useful for shell-servers that like to keep track
63038 + of their users. If the sysctl option is enabled, a sysctl option with
63039 + name "exec_logging" is created.
63040 + WARNING: This option when enabled will produce a LOT of logs, especially
63041 + on an active system.
63042 +
63043 +config GRKERNSEC_RESLOG
63044 + bool "Resource logging"
63045 + default y if GRKERNSEC_CONFIG_AUTO
63046 + help
63047 + If you say Y here, all attempts to overstep resource limits will
63048 + be logged with the resource name, the requested size, and the current
63049 + limit. It is highly recommended that you say Y here. If the sysctl
63050 + option is enabled, a sysctl option with name "resource_logging" is
63051 + created. If the RBAC system is enabled, the sysctl value is ignored.
63052 +
63053 +config GRKERNSEC_CHROOT_EXECLOG
63054 + bool "Log execs within chroot"
63055 + help
63056 + If you say Y here, all executions inside a chroot jail will be logged
63057 + to syslog. This can cause a large amount of logs if certain
63058 + applications (eg. djb's daemontools) are installed on the system, and
63059 + is therefore left as an option. If the sysctl option is enabled, a
63060 + sysctl option with name "chroot_execlog" is created.
63061 +
63062 +config GRKERNSEC_AUDIT_PTRACE
63063 + bool "Ptrace logging"
63064 + help
63065 + If you say Y here, all attempts to attach to a process via ptrace
63066 + will be logged. If the sysctl option is enabled, a sysctl option
63067 + with name "audit_ptrace" is created.
63068 +
63069 +config GRKERNSEC_AUDIT_CHDIR
63070 + bool "Chdir logging"
63071 + help
63072 + If you say Y here, all chdir() calls will be logged. If the sysctl
63073 + option is enabled, a sysctl option with name "audit_chdir" is created.
63074 +
63075 +config GRKERNSEC_AUDIT_MOUNT
63076 + bool "(Un)Mount logging"
63077 + help
63078 + If you say Y here, all mounts and unmounts will be logged. If the
63079 + sysctl option is enabled, a sysctl option with name "audit_mount" is
63080 + created.
63081 +
63082 +config GRKERNSEC_SIGNAL
63083 + bool "Signal logging"
63084 + default y if GRKERNSEC_CONFIG_AUTO
63085 + help
63086 + If you say Y here, certain important signals will be logged, such as
63087 + SIGSEGV, which will as a result inform you of when a error in a program
63088 + occurred, which in some cases could mean a possible exploit attempt.
63089 + If the sysctl option is enabled, a sysctl option with name
63090 + "signal_logging" is created.
63091 +
63092 +config GRKERNSEC_FORKFAIL
63093 + bool "Fork failure logging"
63094 + help
63095 + If you say Y here, all failed fork() attempts will be logged.
63096 + This could suggest a fork bomb, or someone attempting to overstep
63097 + their process limit. If the sysctl option is enabled, a sysctl option
63098 + with name "forkfail_logging" is created.
63099 +
63100 +config GRKERNSEC_TIME
63101 + bool "Time change logging"
63102 + default y if GRKERNSEC_CONFIG_AUTO
63103 + help
63104 + If you say Y here, any changes of the system clock will be logged.
63105 + If the sysctl option is enabled, a sysctl option with name
63106 + "timechange_logging" is created.
63107 +
63108 +config GRKERNSEC_PROC_IPADDR
63109 + bool "/proc/<pid>/ipaddr support"
63110 + default y if GRKERNSEC_CONFIG_AUTO
63111 + help
63112 + If you say Y here, a new entry will be added to each /proc/<pid>
63113 + directory that contains the IP address of the person using the task.
63114 + The IP is carried across local TCP and AF_UNIX stream sockets.
63115 + This information can be useful for IDS/IPSes to perform remote response
63116 + to a local attack. The entry is readable by only the owner of the
63117 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
63118 + the RBAC system), and thus does not create privacy concerns.
63119 +
63120 +config GRKERNSEC_RWXMAP_LOG
63121 + bool 'Denied RWX mmap/mprotect logging'
63122 + default y if GRKERNSEC_CONFIG_AUTO
63123 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
63124 + help
63125 + If you say Y here, calls to mmap() and mprotect() with explicit
63126 + usage of PROT_WRITE and PROT_EXEC together will be logged when
63127 + denied by the PAX_MPROTECT feature. This feature will also
63128 + log other problematic scenarios that can occur when PAX_MPROTECT
63129 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
63130 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
63131 + is created.
63132 +
63133 +endmenu
63134 +
63135 +menu "Executable Protections"
63136 +depends on GRKERNSEC
63137 +
63138 +config GRKERNSEC_DMESG
63139 + bool "Dmesg(8) restriction"
63140 + default y if GRKERNSEC_CONFIG_AUTO
63141 + help
63142 + If you say Y here, non-root users will not be able to use dmesg(8)
63143 + to view the contents of the kernel's circular log buffer.
63144 + The kernel's log buffer often contains kernel addresses and other
63145 + identifying information useful to an attacker in fingerprinting a
63146 + system for a targeted exploit.
63147 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
63148 + created.
63149 +
63150 +config GRKERNSEC_HARDEN_PTRACE
63151 + bool "Deter ptrace-based process snooping"
63152 + default y if GRKERNSEC_CONFIG_AUTO
63153 + help
63154 + If you say Y here, TTY sniffers and other malicious monitoring
63155 + programs implemented through ptrace will be defeated. If you
63156 + have been using the RBAC system, this option has already been
63157 + enabled for several years for all users, with the ability to make
63158 + fine-grained exceptions.
63159 +
63160 + This option only affects the ability of non-root users to ptrace
63161 + processes that are not a descendent of the ptracing process.
63162 + This means that strace ./binary and gdb ./binary will still work,
63163 + but attaching to arbitrary processes will not. If the sysctl
63164 + option is enabled, a sysctl option with name "harden_ptrace" is
63165 + created.
63166 +
63167 +config GRKERNSEC_PTRACE_READEXEC
63168 + bool "Require read access to ptrace sensitive binaries"
63169 + default y if GRKERNSEC_CONFIG_AUTO
63170 + help
63171 + If you say Y here, unprivileged users will not be able to ptrace unreadable
63172 + binaries. This option is useful in environments that
63173 + remove the read bits (e.g. file mode 4711) from suid binaries to
63174 + prevent infoleaking of their contents. This option adds
63175 + consistency to the use of that file mode, as the binary could normally
63176 + be read out when run without privileges while ptracing.
63177 +
63178 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
63179 + is created.
63180 +
63181 +config GRKERNSEC_SETXID
63182 + bool "Enforce consistent multithreaded privileges"
63183 + default y if GRKERNSEC_CONFIG_AUTO
63184 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
63185 + help
63186 + If you say Y here, a change from a root uid to a non-root uid
63187 + in a multithreaded application will cause the resulting uids,
63188 + gids, supplementary groups, and capabilities in that thread
63189 + to be propagated to the other threads of the process. In most
63190 + cases this is unnecessary, as glibc will emulate this behavior
63191 + on behalf of the application. Other libcs do not act in the
63192 + same way, allowing the other threads of the process to continue
63193 + running with root privileges. If the sysctl option is enabled,
63194 + a sysctl option with name "consistent_setxid" is created.
63195 +
63196 +config GRKERNSEC_TPE
63197 + bool "Trusted Path Execution (TPE)"
63198 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63199 + help
63200 + If you say Y here, you will be able to choose a gid to add to the
63201 + supplementary groups of users you want to mark as "untrusted."
63202 + These users will not be able to execute any files that are not in
63203 + root-owned directories writable only by root. If the sysctl option
63204 + is enabled, a sysctl option with name "tpe" is created.
63205 +
63206 +config GRKERNSEC_TPE_ALL
63207 + bool "Partially restrict all non-root users"
63208 + depends on GRKERNSEC_TPE
63209 + help
63210 + If you say Y here, all non-root users will be covered under
63211 + a weaker TPE restriction. This is separate from, and in addition to,
63212 + the main TPE options that you have selected elsewhere. Thus, if a
63213 + "trusted" GID is chosen, this restriction applies to even that GID.
63214 + Under this restriction, all non-root users will only be allowed to
63215 + execute files in directories they own that are not group or
63216 + world-writable, or in directories owned by root and writable only by
63217 + root. If the sysctl option is enabled, a sysctl option with name
63218 + "tpe_restrict_all" is created.
63219 +
63220 +config GRKERNSEC_TPE_INVERT
63221 + bool "Invert GID option"
63222 + depends on GRKERNSEC_TPE
63223 + help
63224 + If you say Y here, the group you specify in the TPE configuration will
63225 + decide what group TPE restrictions will be *disabled* for. This
63226 + option is useful if you want TPE restrictions to be applied to most
63227 + users on the system. If the sysctl option is enabled, a sysctl option
63228 + with name "tpe_invert" is created. Unlike other sysctl options, this
63229 + entry will default to on for backward-compatibility.
63230 +
63231 +config GRKERNSEC_TPE_GID
63232 + int
63233 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
63234 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
63235 +
63236 +config GRKERNSEC_TPE_UNTRUSTED_GID
63237 + int "GID for TPE-untrusted users"
63238 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
63239 + default 1005
63240 + help
63241 + Setting this GID determines what group TPE restrictions will be
63242 + *enabled* for. If the sysctl option is enabled, a sysctl option
63243 + with name "tpe_gid" is created.
63244 +
63245 +config GRKERNSEC_TPE_TRUSTED_GID
63246 + int "GID for TPE-trusted users"
63247 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
63248 + default 1005
63249 + help
63250 + Setting this GID determines what group TPE restrictions will be
63251 + *disabled* for. If the sysctl option is enabled, a sysctl option
63252 + with name "tpe_gid" is created.
63253 +
63254 +endmenu
63255 +menu "Network Protections"
63256 +depends on GRKERNSEC
63257 +
63258 +config GRKERNSEC_RANDNET
63259 + bool "Larger entropy pools"
63260 + default y if GRKERNSEC_CONFIG_AUTO
63261 + help
63262 + If you say Y here, the entropy pools used for many features of Linux
63263 + and grsecurity will be doubled in size. Since several grsecurity
63264 + features use additional randomness, it is recommended that you say Y
63265 + here. Saying Y here has a similar effect as modifying
63266 + /proc/sys/kernel/random/poolsize.
63267 +
63268 +config GRKERNSEC_BLACKHOLE
63269 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
63270 + default y if GRKERNSEC_CONFIG_AUTO
63271 + depends on NET
63272 + help
63273 + If you say Y here, neither TCP resets nor ICMP
63274 + destination-unreachable packets will be sent in response to packets
63275 + sent to ports for which no associated listening process exists.
63276 + This feature supports both IPV4 and IPV6 and exempts the
63277 + loopback interface from blackholing. Enabling this feature
63278 + makes a host more resilient to DoS attacks and reduces network
63279 + visibility against scanners.
63280 +
63281 + The blackhole feature as-implemented is equivalent to the FreeBSD
63282 + blackhole feature, as it prevents RST responses to all packets, not
63283 + just SYNs. Under most application behavior this causes no
63284 + problems, but applications (like haproxy) may not close certain
63285 + connections in a way that cleanly terminates them on the remote
63286 + end, leaving the remote host in LAST_ACK state. Because of this
63287 + side-effect and to prevent intentional LAST_ACK DoSes, this
63288 + feature also adds automatic mitigation against such attacks.
63289 + The mitigation drastically reduces the amount of time a socket
63290 + can spend in LAST_ACK state. If you're using haproxy and not
63291 + all servers it connects to have this option enabled, consider
63292 + disabling this feature on the haproxy host.
63293 +
63294 + If the sysctl option is enabled, two sysctl options with names
63295 + "ip_blackhole" and "lastack_retries" will be created.
63296 + While "ip_blackhole" takes the standard zero/non-zero on/off
63297 + toggle, "lastack_retries" uses the same kinds of values as
63298 + "tcp_retries1" and "tcp_retries2". The default value of 4
63299 + prevents a socket from lasting more than 45 seconds in LAST_ACK
63300 + state.
63301 +
63302 +config GRKERNSEC_NO_SIMULT_CONNECT
63303 + bool "Disable TCP Simultaneous Connect"
63304 + default y if GRKERNSEC_CONFIG_AUTO
63305 + depends on NET
63306 + help
63307 + If you say Y here, a feature by Willy Tarreau will be enabled that
63308 + removes a weakness in Linux's strict implementation of TCP that
63309 + allows two clients to connect to each other without either entering
63310 + a listening state. The weakness allows an attacker to easily prevent
63311 + a client from connecting to a known server provided the source port
63312 + for the connection is guessed correctly.
63313 +
63314 + As the weakness could be used to prevent an antivirus or IPS from
63315 + fetching updates, or prevent an SSL gateway from fetching a CRL,
63316 + it should be eliminated by enabling this option. Though Linux is
63317 + one of few operating systems supporting simultaneous connect, it
63318 + has no legitimate use in practice and is rarely supported by firewalls.
63319 +
63320 +config GRKERNSEC_SOCKET
63321 + bool "Socket restrictions"
63322 + depends on NET
63323 + help
63324 + If you say Y here, you will be able to choose from several options.
63325 + If you assign a GID on your system and add it to the supplementary
63326 + groups of users you want to restrict socket access to, this patch
63327 + will perform up to three things, based on the option(s) you choose.
63328 +
63329 +config GRKERNSEC_SOCKET_ALL
63330 + bool "Deny any sockets to group"
63331 + depends on GRKERNSEC_SOCKET
63332 + help
63333 + If you say Y here, you will be able to choose a GID of whose users will
63334 + be unable to connect to other hosts from your machine or run server
63335 + applications from your machine. If the sysctl option is enabled, a
63336 + sysctl option with name "socket_all" is created.
63337 +
63338 +config GRKERNSEC_SOCKET_ALL_GID
63339 + int "GID to deny all sockets for"
63340 + depends on GRKERNSEC_SOCKET_ALL
63341 + default 1004
63342 + help
63343 + Here you can choose the GID to disable socket access for. Remember to
63344 + add the users you want socket access disabled for to the GID
63345 + specified here. If the sysctl option is enabled, a sysctl option
63346 + with name "socket_all_gid" is created.
63347 +
63348 +config GRKERNSEC_SOCKET_CLIENT
63349 + bool "Deny client sockets to group"
63350 + depends on GRKERNSEC_SOCKET
63351 + help
63352 + If you say Y here, you will be able to choose a GID of whose users will
63353 + be unable to connect to other hosts from your machine, but will be
63354 + able to run servers. If this option is enabled, all users in the group
63355 + you specify will have to use passive mode when initiating ftp transfers
63356 + from the shell on your machine. If the sysctl option is enabled, a
63357 + sysctl option with name "socket_client" is created.
63358 +
63359 +config GRKERNSEC_SOCKET_CLIENT_GID
63360 + int "GID to deny client sockets for"
63361 + depends on GRKERNSEC_SOCKET_CLIENT
63362 + default 1003
63363 + help
63364 + Here you can choose the GID to disable client socket access for.
63365 + Remember to add the users you want client socket access disabled for to
63366 + the GID specified here. If the sysctl option is enabled, a sysctl
63367 + option with name "socket_client_gid" is created.
63368 +
63369 +config GRKERNSEC_SOCKET_SERVER
63370 + bool "Deny server sockets to group"
63371 + depends on GRKERNSEC_SOCKET
63372 + help
63373 + If you say Y here, you will be able to choose a GID of whose users will
63374 + be unable to run server applications from your machine. If the sysctl
63375 + option is enabled, a sysctl option with name "socket_server" is created.
63376 +
63377 +config GRKERNSEC_SOCKET_SERVER_GID
63378 + int "GID to deny server sockets for"
63379 + depends on GRKERNSEC_SOCKET_SERVER
63380 + default 1002
63381 + help
63382 + Here you can choose the GID to disable server socket access for.
63383 + Remember to add the users you want server socket access disabled for to
63384 + the GID specified here. If the sysctl option is enabled, a sysctl
63385 + option with name "socket_server_gid" is created.
63386 +
63387 +endmenu
63388 +
63389 +menu "Physical Protections"
63390 +depends on GRKERNSEC
63391 +
63392 +config GRKERNSEC_DENYUSB
63393 + bool "Deny new USB connections after toggle"
63394 + default y if GRKERNSEC_CONFIG_AUTO
63395 + help
63396 + If you say Y here, a new sysctl option with name "deny_new_usb"
63397 + will be created. Setting its value to 1 will prevent any new
63398 + USB devices from being recognized by the OS. Any attempted USB
63399 + device insertion will be logged. This option is intended to be
63400 + used against custom USB devices designed to exploit vulnerabilities
63401 + in various USB device drivers.
63402 +
63403 + For greatest effectiveness, this sysctl should be set after any
63404 + relevant init scripts. This option is safe to enable in distros
63405 + as each user can choose whether or not to toggle the sysctl.
63406 +
63407 +config GRKERNSEC_DENYUSB_FORCE
63408 + bool "Reject all USB devices not connected at boot"
63409 + select USB
63410 + depends on SYSCTL && GRKERNSEC_DENYUSB
63411 + help
63412 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
63413 + that doesn't involve a sysctl entry. This option should only be
63414 + enabled if you're sure you want to deny all new USB connections
63415 + at runtime and don't want to modify init scripts. This should not
63416 + be enabled by distros. It forces the core USB code to be built
63417 + into the kernel image so that all devices connected at boot time
63418 + can be recognized and new USB device connections can be prevented
63419 + prior to init running.
63420 +
63421 +endmenu
63422 +
63423 +menu "Sysctl Support"
63424 +depends on GRKERNSEC && SYSCTL
63425 +
63426 +config GRKERNSEC_SYSCTL
63427 + bool "Sysctl support"
63428 + default y if GRKERNSEC_CONFIG_AUTO
63429 + help
63430 + If you say Y here, you will be able to change the options that
63431 + grsecurity runs with at bootup, without having to recompile your
63432 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
63433 + to enable (1) or disable (0) various features. All the sysctl entries
63434 + are mutable until the "grsec_lock" entry is set to a non-zero value.
63435 + All features enabled in the kernel configuration are disabled at boot
63436 + if you do not say Y to the "Turn on features by default" option.
63437 + All options should be set at startup, and the grsec_lock entry should
63438 + be set to a non-zero value after all the options are set.
63439 + *THIS IS EXTREMELY IMPORTANT*
63440 +
63441 +config GRKERNSEC_SYSCTL_DISTRO
63442 + bool "Extra sysctl support for distro makers (READ HELP)"
63443 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
63444 + help
63445 + If you say Y here, additional sysctl options will be created
63446 + for features that affect processes running as root. Therefore,
63447 + it is critical when using this option that the grsec_lock entry be
63448 + enabled after boot. Only distros with prebuilt kernel packages
63449 + with this option enabled that can ensure grsec_lock is enabled
63450 + after boot should use this option.
63451 + *Failure to set grsec_lock after boot makes all grsec features
63452 + this option covers useless*
63453 +
63454 + Currently this option creates the following sysctl entries:
63455 + "Disable Privileged I/O": "disable_priv_io"
63456 +
63457 +config GRKERNSEC_SYSCTL_ON
63458 + bool "Turn on features by default"
63459 + default y if GRKERNSEC_CONFIG_AUTO
63460 + depends on GRKERNSEC_SYSCTL
63461 + help
63462 + If you say Y here, instead of having all features enabled in the
63463 + kernel configuration disabled at boot time, the features will be
63464 + enabled at boot time. It is recommended you say Y here unless
63465 + there is some reason you would want all sysctl-tunable features to
63466 + be disabled by default. As mentioned elsewhere, it is important
63467 + to enable the grsec_lock entry once you have finished modifying
63468 + the sysctl entries.
63469 +
63470 +endmenu
63471 +menu "Logging Options"
63472 +depends on GRKERNSEC
63473 +
63474 +config GRKERNSEC_FLOODTIME
63475 + int "Seconds in between log messages (minimum)"
63476 + default 10
63477 + help
63478 + This option allows you to enforce the number of seconds between
63479 + grsecurity log messages. The default should be suitable for most
63480 + people, however, if you choose to change it, choose a value small enough
63481 + to allow informative logs to be produced, but large enough to
63482 + prevent flooding.
63483 +
63484 +config GRKERNSEC_FLOODBURST
63485 + int "Number of messages in a burst (maximum)"
63486 + default 6
63487 + help
63488 + This option allows you to choose the maximum number of messages allowed
63489 + within the flood time interval you chose in a separate option. The
63490 + default should be suitable for most people, however if you find that
63491 + many of your logs are being interpreted as flooding, you may want to
63492 + raise this value.
63493 +
63494 +endmenu
63495 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
63496 new file mode 100644
63497 index 0000000..b0b77d5
63498 --- /dev/null
63499 +++ b/grsecurity/Makefile
63500 @@ -0,0 +1,43 @@
63501 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
63502 +# during 2001-2009 it has been completely redesigned by Brad Spengler
63503 +# into an RBAC system
63504 +#
63505 +# All code in this directory and various hooks inserted throughout the kernel
63506 +# are copyright Brad Spengler - Open Source Security, Inc., and released
63507 +# under the GPL v2 or higher
63508 +
63509 +KBUILD_CFLAGS += -Werror
63510 +
63511 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
63512 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
63513 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
63514 + grsec_usb.o
63515 +
63516 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
63517 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
63518 + gracl_learn.o grsec_log.o
63519 +ifdef CONFIG_COMPAT
63520 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
63521 +endif
63522 +
63523 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
63524 +
63525 +ifdef CONFIG_NET
63526 +obj-y += grsec_sock.o
63527 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
63528 +endif
63529 +
63530 +ifndef CONFIG_GRKERNSEC
63531 +obj-y += grsec_disabled.o
63532 +endif
63533 +
63534 +ifdef CONFIG_GRKERNSEC_HIDESYM
63535 +extra-y := grsec_hidesym.o
63536 +$(obj)/grsec_hidesym.o:
63537 + @-chmod -f 500 /boot
63538 + @-chmod -f 500 /lib/modules
63539 + @-chmod -f 500 /lib64/modules
63540 + @-chmod -f 500 /lib32/modules
63541 + @-chmod -f 700 .
63542 + @echo ' grsec: protected kernel image paths'
63543 +endif
63544 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
63545 new file mode 100644
63546 index 0000000..c0793fd
63547 --- /dev/null
63548 +++ b/grsecurity/gracl.c
63549 @@ -0,0 +1,4178 @@
63550 +#include <linux/kernel.h>
63551 +#include <linux/module.h>
63552 +#include <linux/sched.h>
63553 +#include <linux/mm.h>
63554 +#include <linux/file.h>
63555 +#include <linux/fs.h>
63556 +#include <linux/namei.h>
63557 +#include <linux/mount.h>
63558 +#include <linux/tty.h>
63559 +#include <linux/proc_fs.h>
63560 +#include <linux/lglock.h>
63561 +#include <linux/slab.h>
63562 +#include <linux/vmalloc.h>
63563 +#include <linux/types.h>
63564 +#include <linux/sysctl.h>
63565 +#include <linux/netdevice.h>
63566 +#include <linux/ptrace.h>
63567 +#include <linux/gracl.h>
63568 +#include <linux/gralloc.h>
63569 +#include <linux/security.h>
63570 +#include <linux/grinternal.h>
63571 +#include <linux/pid_namespace.h>
63572 +#include <linux/stop_machine.h>
63573 +#include <linux/fdtable.h>
63574 +#include <linux/percpu.h>
63575 +#include <linux/lglock.h>
63576 +#include <linux/hugetlb.h>
63577 +#include <linux/posix-timers.h>
63578 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63579 +#include <linux/magic.h>
63580 +#include <linux/pagemap.h>
63581 +#include "../fs/btrfs/async-thread.h"
63582 +#include "../fs/btrfs/ctree.h"
63583 +#include "../fs/btrfs/btrfs_inode.h"
63584 +#endif
63585 +#include "../fs/mount.h"
63586 +
63587 +#include <asm/uaccess.h>
63588 +#include <asm/errno.h>
63589 +#include <asm/mman.h>
63590 +
63591 +extern struct lglock vfsmount_lock;
63592 +
63593 +static struct acl_role_db acl_role_set;
63594 +static struct name_db name_set;
63595 +static struct inodev_db inodev_set;
63596 +
63597 +/* for keeping track of userspace pointers used for subjects, so we
63598 + can share references in the kernel as well
63599 +*/
63600 +
63601 +static struct path real_root;
63602 +
63603 +static struct acl_subj_map_db subj_map_set;
63604 +
63605 +static struct acl_role_label *default_role;
63606 +
63607 +static struct acl_role_label *role_list;
63608 +
63609 +static u16 acl_sp_role_value;
63610 +
63611 +extern char *gr_shared_page[4];
63612 +static DEFINE_MUTEX(gr_dev_mutex);
63613 +DEFINE_RWLOCK(gr_inode_lock);
63614 +
63615 +struct gr_arg *gr_usermode;
63616 +
63617 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
63618 +
63619 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
63620 +extern void gr_clear_learn_entries(void);
63621 +
63622 +unsigned char *gr_system_salt;
63623 +unsigned char *gr_system_sum;
63624 +
63625 +static struct sprole_pw **acl_special_roles = NULL;
63626 +static __u16 num_sprole_pws = 0;
63627 +
63628 +static struct acl_role_label *kernel_role = NULL;
63629 +
63630 +static unsigned int gr_auth_attempts = 0;
63631 +static unsigned long gr_auth_expires = 0UL;
63632 +
63633 +#ifdef CONFIG_NET
63634 +extern struct vfsmount *sock_mnt;
63635 +#endif
63636 +
63637 +extern struct vfsmount *pipe_mnt;
63638 +extern struct vfsmount *shm_mnt;
63639 +
63640 +#ifdef CONFIG_HUGETLBFS
63641 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
63642 +#endif
63643 +
63644 +static struct acl_object_label *fakefs_obj_rw;
63645 +static struct acl_object_label *fakefs_obj_rwx;
63646 +
63647 +extern int gr_init_uidset(void);
63648 +extern void gr_free_uidset(void);
63649 +extern void gr_remove_uid(uid_t uid);
63650 +extern int gr_find_uid(uid_t uid);
63651 +
63652 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
63653 +{
63654 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
63655 + return -EFAULT;
63656 +
63657 + return 0;
63658 +}
63659 +
63660 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
63661 +{
63662 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
63663 + return -EFAULT;
63664 +
63665 + return 0;
63666 +}
63667 +
63668 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
63669 +{
63670 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
63671 + return -EFAULT;
63672 +
63673 + return 0;
63674 +}
63675 +
63676 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
63677 +{
63678 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
63679 + return -EFAULT;
63680 +
63681 + return 0;
63682 +}
63683 +
63684 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
63685 +{
63686 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
63687 + return -EFAULT;
63688 +
63689 + return 0;
63690 +}
63691 +
63692 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
63693 +{
63694 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
63695 + return -EFAULT;
63696 +
63697 + return 0;
63698 +}
63699 +
63700 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
63701 +{
63702 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
63703 + return -EFAULT;
63704 +
63705 + return 0;
63706 +}
63707 +
63708 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
63709 +{
63710 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
63711 + return -EFAULT;
63712 +
63713 + return 0;
63714 +}
63715 +
63716 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
63717 +{
63718 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
63719 + return -EFAULT;
63720 +
63721 + return 0;
63722 +}
63723 +
63724 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
63725 +{
63726 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
63727 + return -EFAULT;
63728 +
63729 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
63730 + return -EINVAL;
63731 +
63732 + return 0;
63733 +}
63734 +
63735 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
63736 +{
63737 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
63738 + return -EFAULT;
63739 +
63740 + return 0;
63741 +}
63742 +
63743 +static size_t get_gr_arg_wrapper_size_normal(void)
63744 +{
63745 + return sizeof(struct gr_arg_wrapper);
63746 +}
63747 +
63748 +#ifdef CONFIG_COMPAT
63749 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
63750 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
63751 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
63752 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
63753 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
63754 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
63755 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
63756 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
63757 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
63758 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
63759 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
63760 +extern size_t get_gr_arg_wrapper_size_compat(void);
63761 +
63762 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
63763 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
63764 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
63765 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
63766 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
63767 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
63768 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
63769 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
63770 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
63771 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
63772 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
63773 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
63774 +
63775 +#else
63776 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
63777 +#define copy_gr_arg copy_gr_arg_normal
63778 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
63779 +#define copy_acl_object_label copy_acl_object_label_normal
63780 +#define copy_acl_subject_label copy_acl_subject_label_normal
63781 +#define copy_acl_role_label copy_acl_role_label_normal
63782 +#define copy_acl_ip_label copy_acl_ip_label_normal
63783 +#define copy_pointer_from_array copy_pointer_from_array_normal
63784 +#define copy_sprole_pw copy_sprole_pw_normal
63785 +#define copy_role_transition copy_role_transition_normal
63786 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
63787 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
63788 +#endif
63789 +
63790 +__inline__ int
63791 +gr_acl_is_enabled(void)
63792 +{
63793 + return (gr_status & GR_READY);
63794 +}
63795 +
63796 +static inline dev_t __get_dev(const struct dentry *dentry)
63797 +{
63798 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63799 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63800 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63801 + else
63802 +#endif
63803 + return dentry->d_sb->s_dev;
63804 +}
63805 +
63806 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63807 +{
63808 + return __get_dev(dentry);
63809 +}
63810 +
63811 +static char gr_task_roletype_to_char(struct task_struct *task)
63812 +{
63813 + switch (task->role->roletype &
63814 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
63815 + GR_ROLE_SPECIAL)) {
63816 + case GR_ROLE_DEFAULT:
63817 + return 'D';
63818 + case GR_ROLE_USER:
63819 + return 'U';
63820 + case GR_ROLE_GROUP:
63821 + return 'G';
63822 + case GR_ROLE_SPECIAL:
63823 + return 'S';
63824 + }
63825 +
63826 + return 'X';
63827 +}
63828 +
63829 +char gr_roletype_to_char(void)
63830 +{
63831 + return gr_task_roletype_to_char(current);
63832 +}
63833 +
63834 +__inline__ int
63835 +gr_acl_tpe_check(void)
63836 +{
63837 + if (unlikely(!(gr_status & GR_READY)))
63838 + return 0;
63839 + if (current->role->roletype & GR_ROLE_TPE)
63840 + return 1;
63841 + else
63842 + return 0;
63843 +}
63844 +
63845 +int
63846 +gr_handle_rawio(const struct inode *inode)
63847 +{
63848 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63849 + if (inode && S_ISBLK(inode->i_mode) &&
63850 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
63851 + !capable(CAP_SYS_RAWIO))
63852 + return 1;
63853 +#endif
63854 + return 0;
63855 +}
63856 +
63857 +static int
63858 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
63859 +{
63860 + if (likely(lena != lenb))
63861 + return 0;
63862 +
63863 + return !memcmp(a, b, lena);
63864 +}
63865 +
63866 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
63867 +{
63868 + *buflen -= namelen;
63869 + if (*buflen < 0)
63870 + return -ENAMETOOLONG;
63871 + *buffer -= namelen;
63872 + memcpy(*buffer, str, namelen);
63873 + return 0;
63874 +}
63875 +
63876 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
63877 +{
63878 + return prepend(buffer, buflen, name->name, name->len);
63879 +}
63880 +
63881 +static int prepend_path(const struct path *path, struct path *root,
63882 + char **buffer, int *buflen)
63883 +{
63884 + struct dentry *dentry = path->dentry;
63885 + struct vfsmount *vfsmnt = path->mnt;
63886 + struct mount *mnt = real_mount(vfsmnt);
63887 + bool slash = false;
63888 + int error = 0;
63889 +
63890 + while (dentry != root->dentry || vfsmnt != root->mnt) {
63891 + struct dentry * parent;
63892 +
63893 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
63894 + /* Global root? */
63895 + if (!mnt_has_parent(mnt)) {
63896 + goto out;
63897 + }
63898 + dentry = mnt->mnt_mountpoint;
63899 + mnt = mnt->mnt_parent;
63900 + vfsmnt = &mnt->mnt;
63901 + continue;
63902 + }
63903 + parent = dentry->d_parent;
63904 + prefetch(parent);
63905 + spin_lock(&dentry->d_lock);
63906 + error = prepend_name(buffer, buflen, &dentry->d_name);
63907 + spin_unlock(&dentry->d_lock);
63908 + if (!error)
63909 + error = prepend(buffer, buflen, "/", 1);
63910 + if (error)
63911 + break;
63912 +
63913 + slash = true;
63914 + dentry = parent;
63915 + }
63916 +
63917 +out:
63918 + if (!error && !slash)
63919 + error = prepend(buffer, buflen, "/", 1);
63920 +
63921 + return error;
63922 +}
63923 +
63924 +/* this must be called with vfsmount_lock and rename_lock held */
63925 +
63926 +static char *__our_d_path(const struct path *path, struct path *root,
63927 + char *buf, int buflen)
63928 +{
63929 + char *res = buf + buflen;
63930 + int error;
63931 +
63932 + prepend(&res, &buflen, "\0", 1);
63933 + error = prepend_path(path, root, &res, &buflen);
63934 + if (error)
63935 + return ERR_PTR(error);
63936 +
63937 + return res;
63938 +}
63939 +
63940 +static char *
63941 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63942 +{
63943 + char *retval;
63944 +
63945 + retval = __our_d_path(path, root, buf, buflen);
63946 + if (unlikely(IS_ERR(retval)))
63947 + retval = strcpy(buf, "<path too long>");
63948 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63949 + retval[1] = '\0';
63950 +
63951 + return retval;
63952 +}
63953 +
63954 +static char *
63955 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63956 + char *buf, int buflen)
63957 +{
63958 + struct path path;
63959 + char *res;
63960 +
63961 + path.dentry = (struct dentry *)dentry;
63962 + path.mnt = (struct vfsmount *)vfsmnt;
63963 +
63964 + /* we can use real_root.dentry, real_root.mnt, because this is only called
63965 + by the RBAC system */
63966 + res = gen_full_path(&path, &real_root, buf, buflen);
63967 +
63968 + return res;
63969 +}
63970 +
63971 +static char *
63972 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63973 + char *buf, int buflen)
63974 +{
63975 + char *res;
63976 + struct path path;
63977 + struct path root;
63978 + struct task_struct *reaper = init_pid_ns.child_reaper;
63979 +
63980 + path.dentry = (struct dentry *)dentry;
63981 + path.mnt = (struct vfsmount *)vfsmnt;
63982 +
63983 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
63984 + get_fs_root(reaper->fs, &root);
63985 +
63986 + br_read_lock(&vfsmount_lock);
63987 + write_seqlock(&rename_lock);
63988 + res = gen_full_path(&path, &root, buf, buflen);
63989 + write_sequnlock(&rename_lock);
63990 + br_read_unlock(&vfsmount_lock);
63991 +
63992 + path_put(&root);
63993 + return res;
63994 +}
63995 +
63996 +static char *
63997 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63998 +{
63999 + char *ret;
64000 + br_read_lock(&vfsmount_lock);
64001 + write_seqlock(&rename_lock);
64002 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64003 + PAGE_SIZE);
64004 + write_sequnlock(&rename_lock);
64005 + br_read_unlock(&vfsmount_lock);
64006 + return ret;
64007 +}
64008 +
64009 +static char *
64010 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
64011 +{
64012 + char *ret;
64013 + char *buf;
64014 + int buflen;
64015 +
64016 + br_read_lock(&vfsmount_lock);
64017 + write_seqlock(&rename_lock);
64018 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
64019 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
64020 + buflen = (int)(ret - buf);
64021 + if (buflen >= 5)
64022 + prepend(&ret, &buflen, "/proc", 5);
64023 + else
64024 + ret = strcpy(buf, "<path too long>");
64025 + write_sequnlock(&rename_lock);
64026 + br_read_unlock(&vfsmount_lock);
64027 + return ret;
64028 +}
64029 +
64030 +char *
64031 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
64032 +{
64033 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64034 + PAGE_SIZE);
64035 +}
64036 +
64037 +char *
64038 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
64039 +{
64040 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64041 + PAGE_SIZE);
64042 +}
64043 +
64044 +char *
64045 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
64046 +{
64047 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
64048 + PAGE_SIZE);
64049 +}
64050 +
64051 +char *
64052 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
64053 +{
64054 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
64055 + PAGE_SIZE);
64056 +}
64057 +
64058 +char *
64059 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
64060 +{
64061 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
64062 + PAGE_SIZE);
64063 +}
64064 +
64065 +__inline__ __u32
64066 +to_gr_audit(const __u32 reqmode)
64067 +{
64068 + /* masks off auditable permission flags, then shifts them to create
64069 + auditing flags, and adds the special case of append auditing if
64070 + we're requesting write */
64071 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
64072 +}
64073 +
64074 +struct acl_subject_label *
64075 +lookup_subject_map(const struct acl_subject_label *userp)
64076 +{
64077 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
64078 + struct subject_map *match;
64079 +
64080 + match = subj_map_set.s_hash[index];
64081 +
64082 + while (match && match->user != userp)
64083 + match = match->next;
64084 +
64085 + if (match != NULL)
64086 + return match->kernel;
64087 + else
64088 + return NULL;
64089 +}
64090 +
64091 +static void
64092 +insert_subj_map_entry(struct subject_map *subjmap)
64093 +{
64094 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
64095 + struct subject_map **curr;
64096 +
64097 + subjmap->prev = NULL;
64098 +
64099 + curr = &subj_map_set.s_hash[index];
64100 + if (*curr != NULL)
64101 + (*curr)->prev = subjmap;
64102 +
64103 + subjmap->next = *curr;
64104 + *curr = subjmap;
64105 +
64106 + return;
64107 +}
64108 +
64109 +static struct acl_role_label *
64110 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
64111 + const gid_t gid)
64112 +{
64113 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
64114 + struct acl_role_label *match;
64115 + struct role_allowed_ip *ipp;
64116 + unsigned int x;
64117 + u32 curr_ip = task->signal->curr_ip;
64118 +
64119 + task->signal->saved_ip = curr_ip;
64120 +
64121 + match = acl_role_set.r_hash[index];
64122 +
64123 + while (match) {
64124 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
64125 + for (x = 0; x < match->domain_child_num; x++) {
64126 + if (match->domain_children[x] == uid)
64127 + goto found;
64128 + }
64129 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
64130 + break;
64131 + match = match->next;
64132 + }
64133 +found:
64134 + if (match == NULL) {
64135 + try_group:
64136 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
64137 + match = acl_role_set.r_hash[index];
64138 +
64139 + while (match) {
64140 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
64141 + for (x = 0; x < match->domain_child_num; x++) {
64142 + if (match->domain_children[x] == gid)
64143 + goto found2;
64144 + }
64145 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
64146 + break;
64147 + match = match->next;
64148 + }
64149 +found2:
64150 + if (match == NULL)
64151 + match = default_role;
64152 + if (match->allowed_ips == NULL)
64153 + return match;
64154 + else {
64155 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64156 + if (likely
64157 + ((ntohl(curr_ip) & ipp->netmask) ==
64158 + (ntohl(ipp->addr) & ipp->netmask)))
64159 + return match;
64160 + }
64161 + match = default_role;
64162 + }
64163 + } else if (match->allowed_ips == NULL) {
64164 + return match;
64165 + } else {
64166 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64167 + if (likely
64168 + ((ntohl(curr_ip) & ipp->netmask) ==
64169 + (ntohl(ipp->addr) & ipp->netmask)))
64170 + return match;
64171 + }
64172 + goto try_group;
64173 + }
64174 +
64175 + return match;
64176 +}
64177 +
64178 +struct acl_subject_label *
64179 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
64180 + const struct acl_role_label *role)
64181 +{
64182 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64183 + struct acl_subject_label *match;
64184 +
64185 + match = role->subj_hash[index];
64186 +
64187 + while (match && (match->inode != ino || match->device != dev ||
64188 + (match->mode & GR_DELETED))) {
64189 + match = match->next;
64190 + }
64191 +
64192 + if (match && !(match->mode & GR_DELETED))
64193 + return match;
64194 + else
64195 + return NULL;
64196 +}
64197 +
64198 +struct acl_subject_label *
64199 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
64200 + const struct acl_role_label *role)
64201 +{
64202 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64203 + struct acl_subject_label *match;
64204 +
64205 + match = role->subj_hash[index];
64206 +
64207 + while (match && (match->inode != ino || match->device != dev ||
64208 + !(match->mode & GR_DELETED))) {
64209 + match = match->next;
64210 + }
64211 +
64212 + if (match && (match->mode & GR_DELETED))
64213 + return match;
64214 + else
64215 + return NULL;
64216 +}
64217 +
64218 +static struct acl_object_label *
64219 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
64220 + const struct acl_subject_label *subj)
64221 +{
64222 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64223 + struct acl_object_label *match;
64224 +
64225 + match = subj->obj_hash[index];
64226 +
64227 + while (match && (match->inode != ino || match->device != dev ||
64228 + (match->mode & GR_DELETED))) {
64229 + match = match->next;
64230 + }
64231 +
64232 + if (match && !(match->mode & GR_DELETED))
64233 + return match;
64234 + else
64235 + return NULL;
64236 +}
64237 +
64238 +static struct acl_object_label *
64239 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
64240 + const struct acl_subject_label *subj)
64241 +{
64242 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64243 + struct acl_object_label *match;
64244 +
64245 + match = subj->obj_hash[index];
64246 +
64247 + while (match && (match->inode != ino || match->device != dev ||
64248 + !(match->mode & GR_DELETED))) {
64249 + match = match->next;
64250 + }
64251 +
64252 + if (match && (match->mode & GR_DELETED))
64253 + return match;
64254 +
64255 + match = subj->obj_hash[index];
64256 +
64257 + while (match && (match->inode != ino || match->device != dev ||
64258 + (match->mode & GR_DELETED))) {
64259 + match = match->next;
64260 + }
64261 +
64262 + if (match && !(match->mode & GR_DELETED))
64263 + return match;
64264 + else
64265 + return NULL;
64266 +}
64267 +
64268 +static struct name_entry *
64269 +lookup_name_entry(const char *name)
64270 +{
64271 + unsigned int len = strlen(name);
64272 + unsigned int key = full_name_hash(name, len);
64273 + unsigned int index = key % name_set.n_size;
64274 + struct name_entry *match;
64275 +
64276 + match = name_set.n_hash[index];
64277 +
64278 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
64279 + match = match->next;
64280 +
64281 + return match;
64282 +}
64283 +
64284 +static struct name_entry *
64285 +lookup_name_entry_create(const char *name)
64286 +{
64287 + unsigned int len = strlen(name);
64288 + unsigned int key = full_name_hash(name, len);
64289 + unsigned int index = key % name_set.n_size;
64290 + struct name_entry *match;
64291 +
64292 + match = name_set.n_hash[index];
64293 +
64294 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64295 + !match->deleted))
64296 + match = match->next;
64297 +
64298 + if (match && match->deleted)
64299 + return match;
64300 +
64301 + match = name_set.n_hash[index];
64302 +
64303 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64304 + match->deleted))
64305 + match = match->next;
64306 +
64307 + if (match && !match->deleted)
64308 + return match;
64309 + else
64310 + return NULL;
64311 +}
64312 +
64313 +static struct inodev_entry *
64314 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
64315 +{
64316 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
64317 + struct inodev_entry *match;
64318 +
64319 + match = inodev_set.i_hash[index];
64320 +
64321 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
64322 + match = match->next;
64323 +
64324 + return match;
64325 +}
64326 +
64327 +static void
64328 +insert_inodev_entry(struct inodev_entry *entry)
64329 +{
64330 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
64331 + inodev_set.i_size);
64332 + struct inodev_entry **curr;
64333 +
64334 + entry->prev = NULL;
64335 +
64336 + curr = &inodev_set.i_hash[index];
64337 + if (*curr != NULL)
64338 + (*curr)->prev = entry;
64339 +
64340 + entry->next = *curr;
64341 + *curr = entry;
64342 +
64343 + return;
64344 +}
64345 +
64346 +static void
64347 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
64348 +{
64349 + unsigned int index =
64350 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
64351 + struct acl_role_label **curr;
64352 + struct acl_role_label *tmp, *tmp2;
64353 +
64354 + curr = &acl_role_set.r_hash[index];
64355 +
64356 + /* simple case, slot is empty, just set it to our role */
64357 + if (*curr == NULL) {
64358 + *curr = role;
64359 + } else {
64360 + /* example:
64361 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
64362 + 2 -> 3
64363 + */
64364 + /* first check to see if we can already be reached via this slot */
64365 + tmp = *curr;
64366 + while (tmp && tmp != role)
64367 + tmp = tmp->next;
64368 + if (tmp == role) {
64369 + /* we don't need to add ourselves to this slot's chain */
64370 + return;
64371 + }
64372 + /* we need to add ourselves to this chain, two cases */
64373 + if (role->next == NULL) {
64374 + /* simple case, append the current chain to our role */
64375 + role->next = *curr;
64376 + *curr = role;
64377 + } else {
64378 + /* 1 -> 2 -> 3 -> 4
64379 + 2 -> 3 -> 4
64380 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
64381 + */
64382 + /* trickier case: walk our role's chain until we find
64383 + the role for the start of the current slot's chain */
64384 + tmp = role;
64385 + tmp2 = *curr;
64386 + while (tmp->next && tmp->next != tmp2)
64387 + tmp = tmp->next;
64388 + if (tmp->next == tmp2) {
64389 + /* from example above, we found 3, so just
64390 + replace this slot's chain with ours */
64391 + *curr = role;
64392 + } else {
64393 + /* we didn't find a subset of our role's chain
64394 + in the current slot's chain, so append their
64395 + chain to ours, and set us as the first role in
64396 + the slot's chain
64397 +
64398 + we could fold this case with the case above,
64399 + but making it explicit for clarity
64400 + */
64401 + tmp->next = tmp2;
64402 + *curr = role;
64403 + }
64404 + }
64405 + }
64406 +
64407 + return;
64408 +}
64409 +
64410 +static void
64411 +insert_acl_role_label(struct acl_role_label *role)
64412 +{
64413 + int i;
64414 +
64415 + if (role_list == NULL) {
64416 + role_list = role;
64417 + role->prev = NULL;
64418 + } else {
64419 + role->prev = role_list;
64420 + role_list = role;
64421 + }
64422 +
64423 + /* used for hash chains */
64424 + role->next = NULL;
64425 +
64426 + if (role->roletype & GR_ROLE_DOMAIN) {
64427 + for (i = 0; i < role->domain_child_num; i++)
64428 + __insert_acl_role_label(role, role->domain_children[i]);
64429 + } else
64430 + __insert_acl_role_label(role, role->uidgid);
64431 +}
64432 +
64433 +static int
64434 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
64435 +{
64436 + struct name_entry **curr, *nentry;
64437 + struct inodev_entry *ientry;
64438 + unsigned int len = strlen(name);
64439 + unsigned int key = full_name_hash(name, len);
64440 + unsigned int index = key % name_set.n_size;
64441 +
64442 + curr = &name_set.n_hash[index];
64443 +
64444 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
64445 + curr = &((*curr)->next);
64446 +
64447 + if (*curr != NULL)
64448 + return 1;
64449 +
64450 + nentry = acl_alloc(sizeof (struct name_entry));
64451 + if (nentry == NULL)
64452 + return 0;
64453 + ientry = acl_alloc(sizeof (struct inodev_entry));
64454 + if (ientry == NULL)
64455 + return 0;
64456 + ientry->nentry = nentry;
64457 +
64458 + nentry->key = key;
64459 + nentry->name = name;
64460 + nentry->inode = inode;
64461 + nentry->device = device;
64462 + nentry->len = len;
64463 + nentry->deleted = deleted;
64464 +
64465 + nentry->prev = NULL;
64466 + curr = &name_set.n_hash[index];
64467 + if (*curr != NULL)
64468 + (*curr)->prev = nentry;
64469 + nentry->next = *curr;
64470 + *curr = nentry;
64471 +
64472 + /* insert us into the table searchable by inode/dev */
64473 + insert_inodev_entry(ientry);
64474 +
64475 + return 1;
64476 +}
64477 +
64478 +static void
64479 +insert_acl_obj_label(struct acl_object_label *obj,
64480 + struct acl_subject_label *subj)
64481 +{
64482 + unsigned int index =
64483 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
64484 + struct acl_object_label **curr;
64485 +
64486 +
64487 + obj->prev = NULL;
64488 +
64489 + curr = &subj->obj_hash[index];
64490 + if (*curr != NULL)
64491 + (*curr)->prev = obj;
64492 +
64493 + obj->next = *curr;
64494 + *curr = obj;
64495 +
64496 + return;
64497 +}
64498 +
64499 +static void
64500 +insert_acl_subj_label(struct acl_subject_label *obj,
64501 + struct acl_role_label *role)
64502 +{
64503 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
64504 + struct acl_subject_label **curr;
64505 +
64506 + obj->prev = NULL;
64507 +
64508 + curr = &role->subj_hash[index];
64509 + if (*curr != NULL)
64510 + (*curr)->prev = obj;
64511 +
64512 + obj->next = *curr;
64513 + *curr = obj;
64514 +
64515 + return;
64516 +}
64517 +
64518 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
64519 +
64520 +static void *
64521 +create_table(__u32 * len, int elementsize)
64522 +{
64523 + unsigned int table_sizes[] = {
64524 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
64525 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
64526 + 4194301, 8388593, 16777213, 33554393, 67108859
64527 + };
64528 + void *newtable = NULL;
64529 + unsigned int pwr = 0;
64530 +
64531 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
64532 + table_sizes[pwr] <= *len)
64533 + pwr++;
64534 +
64535 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
64536 + return newtable;
64537 +
64538 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
64539 + newtable =
64540 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
64541 + else
64542 + newtable = vmalloc(table_sizes[pwr] * elementsize);
64543 +
64544 + *len = table_sizes[pwr];
64545 +
64546 + return newtable;
64547 +}
64548 +
64549 +static int
64550 +init_variables(const struct gr_arg *arg)
64551 +{
64552 + struct task_struct *reaper = init_pid_ns.child_reaper;
64553 + unsigned int stacksize;
64554 +
64555 + subj_map_set.s_size = arg->role_db.num_subjects;
64556 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
64557 + name_set.n_size = arg->role_db.num_objects;
64558 + inodev_set.i_size = arg->role_db.num_objects;
64559 +
64560 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
64561 + !name_set.n_size || !inodev_set.i_size)
64562 + return 1;
64563 +
64564 + if (!gr_init_uidset())
64565 + return 1;
64566 +
64567 + /* set up the stack that holds allocation info */
64568 +
64569 + stacksize = arg->role_db.num_pointers + 5;
64570 +
64571 + if (!acl_alloc_stack_init(stacksize))
64572 + return 1;
64573 +
64574 + /* grab reference for the real root dentry and vfsmount */
64575 + get_fs_root(reaper->fs, &real_root);
64576 +
64577 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64578 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
64579 +#endif
64580 +
64581 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
64582 + if (fakefs_obj_rw == NULL)
64583 + return 1;
64584 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
64585 +
64586 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
64587 + if (fakefs_obj_rwx == NULL)
64588 + return 1;
64589 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
64590 +
64591 + subj_map_set.s_hash =
64592 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
64593 + acl_role_set.r_hash =
64594 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
64595 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
64596 + inodev_set.i_hash =
64597 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
64598 +
64599 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
64600 + !name_set.n_hash || !inodev_set.i_hash)
64601 + return 1;
64602 +
64603 + memset(subj_map_set.s_hash, 0,
64604 + sizeof(struct subject_map *) * subj_map_set.s_size);
64605 + memset(acl_role_set.r_hash, 0,
64606 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
64607 + memset(name_set.n_hash, 0,
64608 + sizeof (struct name_entry *) * name_set.n_size);
64609 + memset(inodev_set.i_hash, 0,
64610 + sizeof (struct inodev_entry *) * inodev_set.i_size);
64611 +
64612 + return 0;
64613 +}
64614 +
64615 +/* free information not needed after startup
64616 + currently contains user->kernel pointer mappings for subjects
64617 +*/
64618 +
64619 +static void
64620 +free_init_variables(void)
64621 +{
64622 + __u32 i;
64623 +
64624 + if (subj_map_set.s_hash) {
64625 + for (i = 0; i < subj_map_set.s_size; i++) {
64626 + if (subj_map_set.s_hash[i]) {
64627 + kfree(subj_map_set.s_hash[i]);
64628 + subj_map_set.s_hash[i] = NULL;
64629 + }
64630 + }
64631 +
64632 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
64633 + PAGE_SIZE)
64634 + kfree(subj_map_set.s_hash);
64635 + else
64636 + vfree(subj_map_set.s_hash);
64637 + }
64638 +
64639 + return;
64640 +}
64641 +
64642 +static void
64643 +free_variables(void)
64644 +{
64645 + struct acl_subject_label *s;
64646 + struct acl_role_label *r;
64647 + struct task_struct *task, *task2;
64648 + unsigned int x;
64649 +
64650 + gr_clear_learn_entries();
64651 +
64652 + read_lock(&tasklist_lock);
64653 + do_each_thread(task2, task) {
64654 + task->acl_sp_role = 0;
64655 + task->acl_role_id = 0;
64656 + task->acl = NULL;
64657 + task->role = NULL;
64658 + } while_each_thread(task2, task);
64659 + read_unlock(&tasklist_lock);
64660 +
64661 + /* release the reference to the real root dentry and vfsmount */
64662 + path_put(&real_root);
64663 + memset(&real_root, 0, sizeof(real_root));
64664 +
64665 + /* free all object hash tables */
64666 +
64667 + FOR_EACH_ROLE_START(r)
64668 + if (r->subj_hash == NULL)
64669 + goto next_role;
64670 + FOR_EACH_SUBJECT_START(r, s, x)
64671 + if (s->obj_hash == NULL)
64672 + break;
64673 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
64674 + kfree(s->obj_hash);
64675 + else
64676 + vfree(s->obj_hash);
64677 + FOR_EACH_SUBJECT_END(s, x)
64678 + FOR_EACH_NESTED_SUBJECT_START(r, s)
64679 + if (s->obj_hash == NULL)
64680 + break;
64681 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
64682 + kfree(s->obj_hash);
64683 + else
64684 + vfree(s->obj_hash);
64685 + FOR_EACH_NESTED_SUBJECT_END(s)
64686 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
64687 + kfree(r->subj_hash);
64688 + else
64689 + vfree(r->subj_hash);
64690 + r->subj_hash = NULL;
64691 +next_role:
64692 + FOR_EACH_ROLE_END(r)
64693 +
64694 + acl_free_all();
64695 +
64696 + if (acl_role_set.r_hash) {
64697 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
64698 + PAGE_SIZE)
64699 + kfree(acl_role_set.r_hash);
64700 + else
64701 + vfree(acl_role_set.r_hash);
64702 + }
64703 + if (name_set.n_hash) {
64704 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
64705 + PAGE_SIZE)
64706 + kfree(name_set.n_hash);
64707 + else
64708 + vfree(name_set.n_hash);
64709 + }
64710 +
64711 + if (inodev_set.i_hash) {
64712 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
64713 + PAGE_SIZE)
64714 + kfree(inodev_set.i_hash);
64715 + else
64716 + vfree(inodev_set.i_hash);
64717 + }
64718 +
64719 + gr_free_uidset();
64720 +
64721 + memset(&name_set, 0, sizeof (struct name_db));
64722 + memset(&inodev_set, 0, sizeof (struct inodev_db));
64723 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
64724 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
64725 +
64726 + default_role = NULL;
64727 + kernel_role = NULL;
64728 + role_list = NULL;
64729 +
64730 + return;
64731 +}
64732 +
64733 +static struct acl_subject_label *
64734 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
64735 +
64736 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
64737 +{
64738 + unsigned int len = strnlen_user(*name, maxlen);
64739 + char *tmp;
64740 +
64741 + if (!len || len >= maxlen)
64742 + return -EINVAL;
64743 +
64744 + if ((tmp = (char *) acl_alloc(len)) == NULL)
64745 + return -ENOMEM;
64746 +
64747 + if (copy_from_user(tmp, *name, len))
64748 + return -EFAULT;
64749 +
64750 + tmp[len-1] = '\0';
64751 + *name = tmp;
64752 +
64753 + return 0;
64754 +}
64755 +
64756 +static int
64757 +copy_user_glob(struct acl_object_label *obj)
64758 +{
64759 + struct acl_object_label *g_tmp, **guser;
64760 + int error;
64761 +
64762 + if (obj->globbed == NULL)
64763 + return 0;
64764 +
64765 + guser = &obj->globbed;
64766 + while (*guser) {
64767 + g_tmp = (struct acl_object_label *)
64768 + acl_alloc(sizeof (struct acl_object_label));
64769 + if (g_tmp == NULL)
64770 + return -ENOMEM;
64771 +
64772 + if (copy_acl_object_label(g_tmp, *guser))
64773 + return -EFAULT;
64774 +
64775 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
64776 + if (error)
64777 + return error;
64778 +
64779 + *guser = g_tmp;
64780 + guser = &(g_tmp->next);
64781 + }
64782 +
64783 + return 0;
64784 +}
64785 +
64786 +static int
64787 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
64788 + struct acl_role_label *role)
64789 +{
64790 + struct acl_object_label *o_tmp;
64791 + int ret;
64792 +
64793 + while (userp) {
64794 + if ((o_tmp = (struct acl_object_label *)
64795 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
64796 + return -ENOMEM;
64797 +
64798 + if (copy_acl_object_label(o_tmp, userp))
64799 + return -EFAULT;
64800 +
64801 + userp = o_tmp->prev;
64802 +
64803 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
64804 + if (ret)
64805 + return ret;
64806 +
64807 + insert_acl_obj_label(o_tmp, subj);
64808 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
64809 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
64810 + return -ENOMEM;
64811 +
64812 + ret = copy_user_glob(o_tmp);
64813 + if (ret)
64814 + return ret;
64815 +
64816 + if (o_tmp->nested) {
64817 + int already_copied;
64818 +
64819 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
64820 + if (IS_ERR(o_tmp->nested))
64821 + return PTR_ERR(o_tmp->nested);
64822 +
64823 + /* insert into nested subject list if we haven't copied this one yet
64824 + to prevent duplicate entries */
64825 + if (!already_copied) {
64826 + o_tmp->nested->next = role->hash->first;
64827 + role->hash->first = o_tmp->nested;
64828 + }
64829 + }
64830 + }
64831 +
64832 + return 0;
64833 +}
64834 +
64835 +static __u32
64836 +count_user_subjs(struct acl_subject_label *userp)
64837 +{
64838 + struct acl_subject_label s_tmp;
64839 + __u32 num = 0;
64840 +
64841 + while (userp) {
64842 + if (copy_acl_subject_label(&s_tmp, userp))
64843 + break;
64844 +
64845 + userp = s_tmp.prev;
64846 + }
64847 +
64848 + return num;
64849 +}
64850 +
64851 +static int
64852 +copy_user_allowedips(struct acl_role_label *rolep)
64853 +{
64854 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
64855 +
64856 + ruserip = rolep->allowed_ips;
64857 +
64858 + while (ruserip) {
64859 + rlast = rtmp;
64860 +
64861 + if ((rtmp = (struct role_allowed_ip *)
64862 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
64863 + return -ENOMEM;
64864 +
64865 + if (copy_role_allowed_ip(rtmp, ruserip))
64866 + return -EFAULT;
64867 +
64868 + ruserip = rtmp->prev;
64869 +
64870 + if (!rlast) {
64871 + rtmp->prev = NULL;
64872 + rolep->allowed_ips = rtmp;
64873 + } else {
64874 + rlast->next = rtmp;
64875 + rtmp->prev = rlast;
64876 + }
64877 +
64878 + if (!ruserip)
64879 + rtmp->next = NULL;
64880 + }
64881 +
64882 + return 0;
64883 +}
64884 +
64885 +static int
64886 +copy_user_transitions(struct acl_role_label *rolep)
64887 +{
64888 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
64889 + int error;
64890 +
64891 + rusertp = rolep->transitions;
64892 +
64893 + while (rusertp) {
64894 + rlast = rtmp;
64895 +
64896 + if ((rtmp = (struct role_transition *)
64897 + acl_alloc(sizeof (struct role_transition))) == NULL)
64898 + return -ENOMEM;
64899 +
64900 + if (copy_role_transition(rtmp, rusertp))
64901 + return -EFAULT;
64902 +
64903 + rusertp = rtmp->prev;
64904 +
64905 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
64906 + if (error)
64907 + return error;
64908 +
64909 + if (!rlast) {
64910 + rtmp->prev = NULL;
64911 + rolep->transitions = rtmp;
64912 + } else {
64913 + rlast->next = rtmp;
64914 + rtmp->prev = rlast;
64915 + }
64916 +
64917 + if (!rusertp)
64918 + rtmp->next = NULL;
64919 + }
64920 +
64921 + return 0;
64922 +}
64923 +
64924 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
64925 +{
64926 + struct acl_object_label o_tmp;
64927 + __u32 num = 0;
64928 +
64929 + while (userp) {
64930 + if (copy_acl_object_label(&o_tmp, userp))
64931 + break;
64932 +
64933 + userp = o_tmp.prev;
64934 + num++;
64935 + }
64936 +
64937 + return num;
64938 +}
64939 +
64940 +static struct acl_subject_label *
64941 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
64942 +{
64943 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
64944 + __u32 num_objs;
64945 + struct acl_ip_label **i_tmp, *i_utmp2;
64946 + struct gr_hash_struct ghash;
64947 + struct subject_map *subjmap;
64948 + unsigned int i_num;
64949 + int err;
64950 +
64951 + if (already_copied != NULL)
64952 + *already_copied = 0;
64953 +
64954 + s_tmp = lookup_subject_map(userp);
64955 +
64956 + /* we've already copied this subject into the kernel, just return
64957 + the reference to it, and don't copy it over again
64958 + */
64959 + if (s_tmp) {
64960 + if (already_copied != NULL)
64961 + *already_copied = 1;
64962 + return(s_tmp);
64963 + }
64964 +
64965 + if ((s_tmp = (struct acl_subject_label *)
64966 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
64967 + return ERR_PTR(-ENOMEM);
64968 +
64969 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
64970 + if (subjmap == NULL)
64971 + return ERR_PTR(-ENOMEM);
64972 +
64973 + subjmap->user = userp;
64974 + subjmap->kernel = s_tmp;
64975 + insert_subj_map_entry(subjmap);
64976 +
64977 + if (copy_acl_subject_label(s_tmp, userp))
64978 + return ERR_PTR(-EFAULT);
64979 +
64980 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
64981 + if (err)
64982 + return ERR_PTR(err);
64983 +
64984 + if (!strcmp(s_tmp->filename, "/"))
64985 + role->root_label = s_tmp;
64986 +
64987 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
64988 + return ERR_PTR(-EFAULT);
64989 +
64990 + /* copy user and group transition tables */
64991 +
64992 + if (s_tmp->user_trans_num) {
64993 + uid_t *uidlist;
64994 +
64995 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
64996 + if (uidlist == NULL)
64997 + return ERR_PTR(-ENOMEM);
64998 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
64999 + return ERR_PTR(-EFAULT);
65000 +
65001 + s_tmp->user_transitions = uidlist;
65002 + }
65003 +
65004 + if (s_tmp->group_trans_num) {
65005 + gid_t *gidlist;
65006 +
65007 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
65008 + if (gidlist == NULL)
65009 + return ERR_PTR(-ENOMEM);
65010 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
65011 + return ERR_PTR(-EFAULT);
65012 +
65013 + s_tmp->group_transitions = gidlist;
65014 + }
65015 +
65016 + /* set up object hash table */
65017 + num_objs = count_user_objs(ghash.first);
65018 +
65019 + s_tmp->obj_hash_size = num_objs;
65020 + s_tmp->obj_hash =
65021 + (struct acl_object_label **)
65022 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
65023 +
65024 + if (!s_tmp->obj_hash)
65025 + return ERR_PTR(-ENOMEM);
65026 +
65027 + memset(s_tmp->obj_hash, 0,
65028 + s_tmp->obj_hash_size *
65029 + sizeof (struct acl_object_label *));
65030 +
65031 + /* add in objects */
65032 + err = copy_user_objs(ghash.first, s_tmp, role);
65033 +
65034 + if (err)
65035 + return ERR_PTR(err);
65036 +
65037 + /* set pointer for parent subject */
65038 + if (s_tmp->parent_subject) {
65039 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
65040 +
65041 + if (IS_ERR(s_tmp2))
65042 + return s_tmp2;
65043 +
65044 + s_tmp->parent_subject = s_tmp2;
65045 + }
65046 +
65047 + /* add in ip acls */
65048 +
65049 + if (!s_tmp->ip_num) {
65050 + s_tmp->ips = NULL;
65051 + goto insert;
65052 + }
65053 +
65054 + i_tmp =
65055 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
65056 + sizeof (struct acl_ip_label *));
65057 +
65058 + if (!i_tmp)
65059 + return ERR_PTR(-ENOMEM);
65060 +
65061 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
65062 + *(i_tmp + i_num) =
65063 + (struct acl_ip_label *)
65064 + acl_alloc(sizeof (struct acl_ip_label));
65065 + if (!*(i_tmp + i_num))
65066 + return ERR_PTR(-ENOMEM);
65067 +
65068 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
65069 + return ERR_PTR(-EFAULT);
65070 +
65071 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
65072 + return ERR_PTR(-EFAULT);
65073 +
65074 + if ((*(i_tmp + i_num))->iface == NULL)
65075 + continue;
65076 +
65077 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
65078 + if (err)
65079 + return ERR_PTR(err);
65080 + }
65081 +
65082 + s_tmp->ips = i_tmp;
65083 +
65084 +insert:
65085 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
65086 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
65087 + return ERR_PTR(-ENOMEM);
65088 +
65089 + return s_tmp;
65090 +}
65091 +
65092 +static int
65093 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
65094 +{
65095 + struct acl_subject_label s_pre;
65096 + struct acl_subject_label * ret;
65097 + int err;
65098 +
65099 + while (userp) {
65100 + if (copy_acl_subject_label(&s_pre, userp))
65101 + return -EFAULT;
65102 +
65103 + ret = do_copy_user_subj(userp, role, NULL);
65104 +
65105 + err = PTR_ERR(ret);
65106 + if (IS_ERR(ret))
65107 + return err;
65108 +
65109 + insert_acl_subj_label(ret, role);
65110 +
65111 + userp = s_pre.prev;
65112 + }
65113 +
65114 + return 0;
65115 +}
65116 +
65117 +static int
65118 +copy_user_acl(struct gr_arg *arg)
65119 +{
65120 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
65121 + struct acl_subject_label *subj_list;
65122 + struct sprole_pw *sptmp;
65123 + struct gr_hash_struct *ghash;
65124 + uid_t *domainlist;
65125 + unsigned int r_num;
65126 + int err = 0;
65127 + __u16 i;
65128 + __u32 num_subjs;
65129 +
65130 + /* we need a default and kernel role */
65131 + if (arg->role_db.num_roles < 2)
65132 + return -EINVAL;
65133 +
65134 + /* copy special role authentication info from userspace */
65135 +
65136 + num_sprole_pws = arg->num_sprole_pws;
65137 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
65138 +
65139 + if (!acl_special_roles && num_sprole_pws)
65140 + return -ENOMEM;
65141 +
65142 + for (i = 0; i < num_sprole_pws; i++) {
65143 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
65144 + if (!sptmp)
65145 + return -ENOMEM;
65146 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
65147 + return -EFAULT;
65148 +
65149 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
65150 + if (err)
65151 + return err;
65152 +
65153 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65154 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
65155 +#endif
65156 +
65157 + acl_special_roles[i] = sptmp;
65158 + }
65159 +
65160 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
65161 +
65162 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
65163 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
65164 +
65165 + if (!r_tmp)
65166 + return -ENOMEM;
65167 +
65168 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
65169 + return -EFAULT;
65170 +
65171 + if (copy_acl_role_label(r_tmp, r_utmp2))
65172 + return -EFAULT;
65173 +
65174 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
65175 + if (err)
65176 + return err;
65177 +
65178 + if (!strcmp(r_tmp->rolename, "default")
65179 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
65180 + default_role = r_tmp;
65181 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
65182 + kernel_role = r_tmp;
65183 + }
65184 +
65185 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
65186 + return -ENOMEM;
65187 +
65188 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
65189 + return -EFAULT;
65190 +
65191 + r_tmp->hash = ghash;
65192 +
65193 + num_subjs = count_user_subjs(r_tmp->hash->first);
65194 +
65195 + r_tmp->subj_hash_size = num_subjs;
65196 + r_tmp->subj_hash =
65197 + (struct acl_subject_label **)
65198 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
65199 +
65200 + if (!r_tmp->subj_hash)
65201 + return -ENOMEM;
65202 +
65203 + err = copy_user_allowedips(r_tmp);
65204 + if (err)
65205 + return err;
65206 +
65207 + /* copy domain info */
65208 + if (r_tmp->domain_children != NULL) {
65209 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
65210 + if (domainlist == NULL)
65211 + return -ENOMEM;
65212 +
65213 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
65214 + return -EFAULT;
65215 +
65216 + r_tmp->domain_children = domainlist;
65217 + }
65218 +
65219 + err = copy_user_transitions(r_tmp);
65220 + if (err)
65221 + return err;
65222 +
65223 + memset(r_tmp->subj_hash, 0,
65224 + r_tmp->subj_hash_size *
65225 + sizeof (struct acl_subject_label *));
65226 +
65227 + /* acquire the list of subjects, then NULL out
65228 + the list prior to parsing the subjects for this role,
65229 + as during this parsing the list is replaced with a list
65230 + of *nested* subjects for the role
65231 + */
65232 + subj_list = r_tmp->hash->first;
65233 +
65234 + /* set nested subject list to null */
65235 + r_tmp->hash->first = NULL;
65236 +
65237 + err = copy_user_subjs(subj_list, r_tmp);
65238 +
65239 + if (err)
65240 + return err;
65241 +
65242 + insert_acl_role_label(r_tmp);
65243 + }
65244 +
65245 + if (default_role == NULL || kernel_role == NULL)
65246 + return -EINVAL;
65247 +
65248 + return err;
65249 +}
65250 +
65251 +static int
65252 +gracl_init(struct gr_arg *args)
65253 +{
65254 + int error = 0;
65255 +
65256 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
65257 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
65258 +
65259 + if (init_variables(args)) {
65260 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
65261 + error = -ENOMEM;
65262 + free_variables();
65263 + goto out;
65264 + }
65265 +
65266 + error = copy_user_acl(args);
65267 + free_init_variables();
65268 + if (error) {
65269 + free_variables();
65270 + goto out;
65271 + }
65272 +
65273 + if ((error = gr_set_acls(0))) {
65274 + free_variables();
65275 + goto out;
65276 + }
65277 +
65278 + pax_open_kernel();
65279 + gr_status |= GR_READY;
65280 + pax_close_kernel();
65281 +
65282 + out:
65283 + return error;
65284 +}
65285 +
65286 +/* derived from glibc fnmatch() 0: match, 1: no match*/
65287 +
65288 +static int
65289 +glob_match(const char *p, const char *n)
65290 +{
65291 + char c;
65292 +
65293 + while ((c = *p++) != '\0') {
65294 + switch (c) {
65295 + case '?':
65296 + if (*n == '\0')
65297 + return 1;
65298 + else if (*n == '/')
65299 + return 1;
65300 + break;
65301 + case '\\':
65302 + if (*n != c)
65303 + return 1;
65304 + break;
65305 + case '*':
65306 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
65307 + if (*n == '/')
65308 + return 1;
65309 + else if (c == '?') {
65310 + if (*n == '\0')
65311 + return 1;
65312 + else
65313 + ++n;
65314 + }
65315 + }
65316 + if (c == '\0') {
65317 + return 0;
65318 + } else {
65319 + const char *endp;
65320 +
65321 + if ((endp = strchr(n, '/')) == NULL)
65322 + endp = n + strlen(n);
65323 +
65324 + if (c == '[') {
65325 + for (--p; n < endp; ++n)
65326 + if (!glob_match(p, n))
65327 + return 0;
65328 + } else if (c == '/') {
65329 + while (*n != '\0' && *n != '/')
65330 + ++n;
65331 + if (*n == '/' && !glob_match(p, n + 1))
65332 + return 0;
65333 + } else {
65334 + for (--p; n < endp; ++n)
65335 + if (*n == c && !glob_match(p, n))
65336 + return 0;
65337 + }
65338 +
65339 + return 1;
65340 + }
65341 + case '[':
65342 + {
65343 + int not;
65344 + char cold;
65345 +
65346 + if (*n == '\0' || *n == '/')
65347 + return 1;
65348 +
65349 + not = (*p == '!' || *p == '^');
65350 + if (not)
65351 + ++p;
65352 +
65353 + c = *p++;
65354 + for (;;) {
65355 + unsigned char fn = (unsigned char)*n;
65356 +
65357 + if (c == '\0')
65358 + return 1;
65359 + else {
65360 + if (c == fn)
65361 + goto matched;
65362 + cold = c;
65363 + c = *p++;
65364 +
65365 + if (c == '-' && *p != ']') {
65366 + unsigned char cend = *p++;
65367 +
65368 + if (cend == '\0')
65369 + return 1;
65370 +
65371 + if (cold <= fn && fn <= cend)
65372 + goto matched;
65373 +
65374 + c = *p++;
65375 + }
65376 + }
65377 +
65378 + if (c == ']')
65379 + break;
65380 + }
65381 + if (!not)
65382 + return 1;
65383 + break;
65384 + matched:
65385 + while (c != ']') {
65386 + if (c == '\0')
65387 + return 1;
65388 +
65389 + c = *p++;
65390 + }
65391 + if (not)
65392 + return 1;
65393 + }
65394 + break;
65395 + default:
65396 + if (c != *n)
65397 + return 1;
65398 + }
65399 +
65400 + ++n;
65401 + }
65402 +
65403 + if (*n == '\0')
65404 + return 0;
65405 +
65406 + if (*n == '/')
65407 + return 0;
65408 +
65409 + return 1;
65410 +}
65411 +
65412 +static struct acl_object_label *
65413 +chk_glob_label(struct acl_object_label *globbed,
65414 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
65415 +{
65416 + struct acl_object_label *tmp;
65417 +
65418 + if (*path == NULL)
65419 + *path = gr_to_filename_nolock(dentry, mnt);
65420 +
65421 + tmp = globbed;
65422 +
65423 + while (tmp) {
65424 + if (!glob_match(tmp->filename, *path))
65425 + return tmp;
65426 + tmp = tmp->next;
65427 + }
65428 +
65429 + return NULL;
65430 +}
65431 +
65432 +static struct acl_object_label *
65433 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
65434 + const ino_t curr_ino, const dev_t curr_dev,
65435 + const struct acl_subject_label *subj, char **path, const int checkglob)
65436 +{
65437 + struct acl_subject_label *tmpsubj;
65438 + struct acl_object_label *retval;
65439 + struct acl_object_label *retval2;
65440 +
65441 + tmpsubj = (struct acl_subject_label *) subj;
65442 + read_lock(&gr_inode_lock);
65443 + do {
65444 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
65445 + if (retval) {
65446 + if (checkglob && retval->globbed) {
65447 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
65448 + if (retval2)
65449 + retval = retval2;
65450 + }
65451 + break;
65452 + }
65453 + } while ((tmpsubj = tmpsubj->parent_subject));
65454 + read_unlock(&gr_inode_lock);
65455 +
65456 + return retval;
65457 +}
65458 +
65459 +static __inline__ struct acl_object_label *
65460 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
65461 + struct dentry *curr_dentry,
65462 + const struct acl_subject_label *subj, char **path, const int checkglob)
65463 +{
65464 + int newglob = checkglob;
65465 + ino_t inode;
65466 + dev_t device;
65467 +
65468 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
65469 + as we don't want a / * rule to match instead of the / object
65470 + don't do this for create lookups that call this function though, since they're looking up
65471 + on the parent and thus need globbing checks on all paths
65472 + */
65473 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
65474 + newglob = GR_NO_GLOB;
65475 +
65476 + spin_lock(&curr_dentry->d_lock);
65477 + inode = curr_dentry->d_inode->i_ino;
65478 + device = __get_dev(curr_dentry);
65479 + spin_unlock(&curr_dentry->d_lock);
65480 +
65481 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
65482 +}
65483 +
65484 +#ifdef CONFIG_HUGETLBFS
65485 +static inline bool
65486 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
65487 +{
65488 + int i;
65489 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
65490 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
65491 + return true;
65492 + }
65493 +
65494 + return false;
65495 +}
65496 +#endif
65497 +
65498 +static struct acl_object_label *
65499 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65500 + const struct acl_subject_label *subj, char *path, const int checkglob)
65501 +{
65502 + struct dentry *dentry = (struct dentry *) l_dentry;
65503 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
65504 + struct mount *real_mnt = real_mount(mnt);
65505 + struct acl_object_label *retval;
65506 + struct dentry *parent;
65507 +
65508 + br_read_lock(&vfsmount_lock);
65509 + write_seqlock(&rename_lock);
65510 +
65511 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
65512 +#ifdef CONFIG_NET
65513 + mnt == sock_mnt ||
65514 +#endif
65515 +#ifdef CONFIG_HUGETLBFS
65516 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
65517 +#endif
65518 + /* ignore Eric Biederman */
65519 + IS_PRIVATE(l_dentry->d_inode))) {
65520 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
65521 + goto out;
65522 + }
65523 +
65524 + for (;;) {
65525 + if (dentry == real_root.dentry && mnt == real_root.mnt)
65526 + break;
65527 +
65528 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
65529 + if (!mnt_has_parent(real_mnt))
65530 + break;
65531 +
65532 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
65533 + if (retval != NULL)
65534 + goto out;
65535 +
65536 + dentry = real_mnt->mnt_mountpoint;
65537 + real_mnt = real_mnt->mnt_parent;
65538 + mnt = &real_mnt->mnt;
65539 + continue;
65540 + }
65541 +
65542 + parent = dentry->d_parent;
65543 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
65544 + if (retval != NULL)
65545 + goto out;
65546 +
65547 + dentry = parent;
65548 + }
65549 +
65550 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
65551 +
65552 + /* real_root is pinned so we don't have to hold a reference */
65553 + if (retval == NULL)
65554 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
65555 +out:
65556 + write_sequnlock(&rename_lock);
65557 + br_read_unlock(&vfsmount_lock);
65558 +
65559 + BUG_ON(retval == NULL);
65560 +
65561 + return retval;
65562 +}
65563 +
65564 +static __inline__ struct acl_object_label *
65565 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65566 + const struct acl_subject_label *subj)
65567 +{
65568 + char *path = NULL;
65569 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
65570 +}
65571 +
65572 +static __inline__ struct acl_object_label *
65573 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65574 + const struct acl_subject_label *subj)
65575 +{
65576 + char *path = NULL;
65577 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
65578 +}
65579 +
65580 +static __inline__ struct acl_object_label *
65581 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65582 + const struct acl_subject_label *subj, char *path)
65583 +{
65584 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
65585 +}
65586 +
65587 +static struct acl_subject_label *
65588 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65589 + const struct acl_role_label *role)
65590 +{
65591 + struct dentry *dentry = (struct dentry *) l_dentry;
65592 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
65593 + struct mount *real_mnt = real_mount(mnt);
65594 + struct acl_subject_label *retval;
65595 + struct dentry *parent;
65596 +
65597 + br_read_lock(&vfsmount_lock);
65598 + write_seqlock(&rename_lock);
65599 +
65600 + for (;;) {
65601 + if (dentry == real_root.dentry && mnt == real_root.mnt)
65602 + break;
65603 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
65604 + if (!mnt_has_parent(real_mnt))
65605 + break;
65606 +
65607 + spin_lock(&dentry->d_lock);
65608 + read_lock(&gr_inode_lock);
65609 + retval =
65610 + lookup_acl_subj_label(dentry->d_inode->i_ino,
65611 + __get_dev(dentry), role);
65612 + read_unlock(&gr_inode_lock);
65613 + spin_unlock(&dentry->d_lock);
65614 + if (retval != NULL)
65615 + goto out;
65616 +
65617 + dentry = real_mnt->mnt_mountpoint;
65618 + real_mnt = real_mnt->mnt_parent;
65619 + mnt = &real_mnt->mnt;
65620 + continue;
65621 + }
65622 +
65623 + spin_lock(&dentry->d_lock);
65624 + read_lock(&gr_inode_lock);
65625 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
65626 + __get_dev(dentry), role);
65627 + read_unlock(&gr_inode_lock);
65628 + parent = dentry->d_parent;
65629 + spin_unlock(&dentry->d_lock);
65630 +
65631 + if (retval != NULL)
65632 + goto out;
65633 +
65634 + dentry = parent;
65635 + }
65636 +
65637 + spin_lock(&dentry->d_lock);
65638 + read_lock(&gr_inode_lock);
65639 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
65640 + __get_dev(dentry), role);
65641 + read_unlock(&gr_inode_lock);
65642 + spin_unlock(&dentry->d_lock);
65643 +
65644 + if (unlikely(retval == NULL)) {
65645 + /* real_root is pinned, we don't need to hold a reference */
65646 + read_lock(&gr_inode_lock);
65647 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
65648 + __get_dev(real_root.dentry), role);
65649 + read_unlock(&gr_inode_lock);
65650 + }
65651 +out:
65652 + write_sequnlock(&rename_lock);
65653 + br_read_unlock(&vfsmount_lock);
65654 +
65655 + BUG_ON(retval == NULL);
65656 +
65657 + return retval;
65658 +}
65659 +
65660 +static void
65661 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
65662 +{
65663 + struct task_struct *task = current;
65664 + const struct cred *cred = current_cred();
65665 +
65666 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
65667 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65668 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65669 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
65670 +
65671 + return;
65672 +}
65673 +
65674 +static void
65675 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
65676 +{
65677 + struct task_struct *task = current;
65678 + const struct cred *cred = current_cred();
65679 +
65680 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
65681 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65682 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65683 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
65684 +
65685 + return;
65686 +}
65687 +
65688 +static void
65689 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
65690 +{
65691 + struct task_struct *task = current;
65692 + const struct cred *cred = current_cred();
65693 +
65694 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
65695 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65696 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65697 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
65698 +
65699 + return;
65700 +}
65701 +
65702 +__u32
65703 +gr_search_file(const struct dentry * dentry, const __u32 mode,
65704 + const struct vfsmount * mnt)
65705 +{
65706 + __u32 retval = mode;
65707 + struct acl_subject_label *curracl;
65708 + struct acl_object_label *currobj;
65709 +
65710 + if (unlikely(!(gr_status & GR_READY)))
65711 + return (mode & ~GR_AUDITS);
65712 +
65713 + curracl = current->acl;
65714 +
65715 + currobj = chk_obj_label(dentry, mnt, curracl);
65716 + retval = currobj->mode & mode;
65717 +
65718 + /* if we're opening a specified transfer file for writing
65719 + (e.g. /dev/initctl), then transfer our role to init
65720 + */
65721 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
65722 + current->role->roletype & GR_ROLE_PERSIST)) {
65723 + struct task_struct *task = init_pid_ns.child_reaper;
65724 +
65725 + if (task->role != current->role) {
65726 + task->acl_sp_role = 0;
65727 + task->acl_role_id = current->acl_role_id;
65728 + task->role = current->role;
65729 + rcu_read_lock();
65730 + read_lock(&grsec_exec_file_lock);
65731 + gr_apply_subject_to_task(task);
65732 + read_unlock(&grsec_exec_file_lock);
65733 + rcu_read_unlock();
65734 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
65735 + }
65736 + }
65737 +
65738 + if (unlikely
65739 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
65740 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
65741 + __u32 new_mode = mode;
65742 +
65743 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65744 +
65745 + retval = new_mode;
65746 +
65747 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
65748 + new_mode |= GR_INHERIT;
65749 +
65750 + if (!(mode & GR_NOLEARN))
65751 + gr_log_learn(dentry, mnt, new_mode);
65752 + }
65753 +
65754 + return retval;
65755 +}
65756 +
65757 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
65758 + const struct dentry *parent,
65759 + const struct vfsmount *mnt)
65760 +{
65761 + struct name_entry *match;
65762 + struct acl_object_label *matchpo;
65763 + struct acl_subject_label *curracl;
65764 + char *path;
65765 +
65766 + if (unlikely(!(gr_status & GR_READY)))
65767 + return NULL;
65768 +
65769 + preempt_disable();
65770 + path = gr_to_filename_rbac(new_dentry, mnt);
65771 + match = lookup_name_entry_create(path);
65772 +
65773 + curracl = current->acl;
65774 +
65775 + if (match) {
65776 + read_lock(&gr_inode_lock);
65777 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
65778 + read_unlock(&gr_inode_lock);
65779 +
65780 + if (matchpo) {
65781 + preempt_enable();
65782 + return matchpo;
65783 + }
65784 + }
65785 +
65786 + // lookup parent
65787 +
65788 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
65789 +
65790 + preempt_enable();
65791 + return matchpo;
65792 +}
65793 +
65794 +__u32
65795 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
65796 + const struct vfsmount * mnt, const __u32 mode)
65797 +{
65798 + struct acl_object_label *matchpo;
65799 + __u32 retval;
65800 +
65801 + if (unlikely(!(gr_status & GR_READY)))
65802 + return (mode & ~GR_AUDITS);
65803 +
65804 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
65805 +
65806 + retval = matchpo->mode & mode;
65807 +
65808 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
65809 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65810 + __u32 new_mode = mode;
65811 +
65812 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65813 +
65814 + gr_log_learn(new_dentry, mnt, new_mode);
65815 + return new_mode;
65816 + }
65817 +
65818 + return retval;
65819 +}
65820 +
65821 +__u32
65822 +gr_check_link(const struct dentry * new_dentry,
65823 + const struct dentry * parent_dentry,
65824 + const struct vfsmount * parent_mnt,
65825 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
65826 +{
65827 + struct acl_object_label *obj;
65828 + __u32 oldmode, newmode;
65829 + __u32 needmode;
65830 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
65831 + GR_DELETE | GR_INHERIT;
65832 +
65833 + if (unlikely(!(gr_status & GR_READY)))
65834 + return (GR_CREATE | GR_LINK);
65835 +
65836 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
65837 + oldmode = obj->mode;
65838 +
65839 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
65840 + newmode = obj->mode;
65841 +
65842 + needmode = newmode & checkmodes;
65843 +
65844 + // old name for hardlink must have at least the permissions of the new name
65845 + if ((oldmode & needmode) != needmode)
65846 + goto bad;
65847 +
65848 + // if old name had restrictions/auditing, make sure the new name does as well
65849 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
65850 +
65851 + // don't allow hardlinking of suid/sgid/fcapped files without permission
65852 + if (is_privileged_binary(old_dentry))
65853 + needmode |= GR_SETID;
65854 +
65855 + if ((newmode & needmode) != needmode)
65856 + goto bad;
65857 +
65858 + // enforce minimum permissions
65859 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
65860 + return newmode;
65861 +bad:
65862 + needmode = oldmode;
65863 + if (is_privileged_binary(old_dentry))
65864 + needmode |= GR_SETID;
65865 +
65866 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
65867 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
65868 + return (GR_CREATE | GR_LINK);
65869 + } else if (newmode & GR_SUPPRESS)
65870 + return GR_SUPPRESS;
65871 + else
65872 + return 0;
65873 +}
65874 +
65875 +int
65876 +gr_check_hidden_task(const struct task_struct *task)
65877 +{
65878 + if (unlikely(!(gr_status & GR_READY)))
65879 + return 0;
65880 +
65881 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
65882 + return 1;
65883 +
65884 + return 0;
65885 +}
65886 +
65887 +int
65888 +gr_check_protected_task(const struct task_struct *task)
65889 +{
65890 + if (unlikely(!(gr_status & GR_READY) || !task))
65891 + return 0;
65892 +
65893 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65894 + task->acl != current->acl)
65895 + return 1;
65896 +
65897 + return 0;
65898 +}
65899 +
65900 +int
65901 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65902 +{
65903 + struct task_struct *p;
65904 + int ret = 0;
65905 +
65906 + if (unlikely(!(gr_status & GR_READY) || !pid))
65907 + return ret;
65908 +
65909 + read_lock(&tasklist_lock);
65910 + do_each_pid_task(pid, type, p) {
65911 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65912 + p->acl != current->acl) {
65913 + ret = 1;
65914 + goto out;
65915 + }
65916 + } while_each_pid_task(pid, type, p);
65917 +out:
65918 + read_unlock(&tasklist_lock);
65919 +
65920 + return ret;
65921 +}
65922 +
65923 +void
65924 +gr_copy_label(struct task_struct *tsk)
65925 +{
65926 + tsk->signal->used_accept = 0;
65927 + tsk->acl_sp_role = 0;
65928 + tsk->acl_role_id = current->acl_role_id;
65929 + tsk->acl = current->acl;
65930 + tsk->role = current->role;
65931 + tsk->signal->curr_ip = current->signal->curr_ip;
65932 + tsk->signal->saved_ip = current->signal->saved_ip;
65933 + if (current->exec_file)
65934 + get_file(current->exec_file);
65935 + tsk->exec_file = current->exec_file;
65936 + tsk->is_writable = current->is_writable;
65937 + if (unlikely(current->signal->used_accept)) {
65938 + current->signal->curr_ip = 0;
65939 + current->signal->saved_ip = 0;
65940 + }
65941 +
65942 + return;
65943 +}
65944 +
65945 +static void
65946 +gr_set_proc_res(struct task_struct *task)
65947 +{
65948 + struct acl_subject_label *proc;
65949 + unsigned short i;
65950 +
65951 + proc = task->acl;
65952 +
65953 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
65954 + return;
65955 +
65956 + for (i = 0; i < RLIM_NLIMITS; i++) {
65957 + if (!(proc->resmask & (1U << i)))
65958 + continue;
65959 +
65960 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
65961 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
65962 +
65963 + if (i == RLIMIT_CPU)
65964 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
65965 + }
65966 +
65967 + return;
65968 +}
65969 +
65970 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
65971 +
65972 +int
65973 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65974 +{
65975 + unsigned int i;
65976 + __u16 num;
65977 + uid_t *uidlist;
65978 + uid_t curuid;
65979 + int realok = 0;
65980 + int effectiveok = 0;
65981 + int fsok = 0;
65982 + uid_t globalreal, globaleffective, globalfs;
65983 +
65984 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
65985 + struct user_struct *user;
65986 +
65987 + if (!uid_valid(real))
65988 + goto skipit;
65989 +
65990 + /* find user based on global namespace */
65991 +
65992 + globalreal = GR_GLOBAL_UID(real);
65993 +
65994 + user = find_user(make_kuid(&init_user_ns, globalreal));
65995 + if (user == NULL)
65996 + goto skipit;
65997 +
65998 + if (gr_process_kernel_setuid_ban(user)) {
65999 + /* for find_user */
66000 + free_uid(user);
66001 + return 1;
66002 + }
66003 +
66004 + /* for find_user */
66005 + free_uid(user);
66006 +
66007 +skipit:
66008 +#endif
66009 +
66010 + if (unlikely(!(gr_status & GR_READY)))
66011 + return 0;
66012 +
66013 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66014 + gr_log_learn_uid_change(real, effective, fs);
66015 +
66016 + num = current->acl->user_trans_num;
66017 + uidlist = current->acl->user_transitions;
66018 +
66019 + if (uidlist == NULL)
66020 + return 0;
66021 +
66022 + if (!uid_valid(real)) {
66023 + realok = 1;
66024 + globalreal = (uid_t)-1;
66025 + } else {
66026 + globalreal = GR_GLOBAL_UID(real);
66027 + }
66028 + if (!uid_valid(effective)) {
66029 + effectiveok = 1;
66030 + globaleffective = (uid_t)-1;
66031 + } else {
66032 + globaleffective = GR_GLOBAL_UID(effective);
66033 + }
66034 + if (!uid_valid(fs)) {
66035 + fsok = 1;
66036 + globalfs = (uid_t)-1;
66037 + } else {
66038 + globalfs = GR_GLOBAL_UID(fs);
66039 + }
66040 +
66041 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
66042 + for (i = 0; i < num; i++) {
66043 + curuid = uidlist[i];
66044 + if (globalreal == curuid)
66045 + realok = 1;
66046 + if (globaleffective == curuid)
66047 + effectiveok = 1;
66048 + if (globalfs == curuid)
66049 + fsok = 1;
66050 + }
66051 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
66052 + for (i = 0; i < num; i++) {
66053 + curuid = uidlist[i];
66054 + if (globalreal == curuid)
66055 + break;
66056 + if (globaleffective == curuid)
66057 + break;
66058 + if (globalfs == curuid)
66059 + break;
66060 + }
66061 + /* not in deny list */
66062 + if (i == num) {
66063 + realok = 1;
66064 + effectiveok = 1;
66065 + fsok = 1;
66066 + }
66067 + }
66068 +
66069 + if (realok && effectiveok && fsok)
66070 + return 0;
66071 + else {
66072 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
66073 + return 1;
66074 + }
66075 +}
66076 +
66077 +int
66078 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
66079 +{
66080 + unsigned int i;
66081 + __u16 num;
66082 + gid_t *gidlist;
66083 + gid_t curgid;
66084 + int realok = 0;
66085 + int effectiveok = 0;
66086 + int fsok = 0;
66087 + gid_t globalreal, globaleffective, globalfs;
66088 +
66089 + if (unlikely(!(gr_status & GR_READY)))
66090 + return 0;
66091 +
66092 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66093 + gr_log_learn_gid_change(real, effective, fs);
66094 +
66095 + num = current->acl->group_trans_num;
66096 + gidlist = current->acl->group_transitions;
66097 +
66098 + if (gidlist == NULL)
66099 + return 0;
66100 +
66101 + if (!gid_valid(real)) {
66102 + realok = 1;
66103 + globalreal = (gid_t)-1;
66104 + } else {
66105 + globalreal = GR_GLOBAL_GID(real);
66106 + }
66107 + if (!gid_valid(effective)) {
66108 + effectiveok = 1;
66109 + globaleffective = (gid_t)-1;
66110 + } else {
66111 + globaleffective = GR_GLOBAL_GID(effective);
66112 + }
66113 + if (!gid_valid(fs)) {
66114 + fsok = 1;
66115 + globalfs = (gid_t)-1;
66116 + } else {
66117 + globalfs = GR_GLOBAL_GID(fs);
66118 + }
66119 +
66120 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
66121 + for (i = 0; i < num; i++) {
66122 + curgid = gidlist[i];
66123 + if (globalreal == curgid)
66124 + realok = 1;
66125 + if (globaleffective == curgid)
66126 + effectiveok = 1;
66127 + if (globalfs == curgid)
66128 + fsok = 1;
66129 + }
66130 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
66131 + for (i = 0; i < num; i++) {
66132 + curgid = gidlist[i];
66133 + if (globalreal == curgid)
66134 + break;
66135 + if (globaleffective == curgid)
66136 + break;
66137 + if (globalfs == curgid)
66138 + break;
66139 + }
66140 + /* not in deny list */
66141 + if (i == num) {
66142 + realok = 1;
66143 + effectiveok = 1;
66144 + fsok = 1;
66145 + }
66146 + }
66147 +
66148 + if (realok && effectiveok && fsok)
66149 + return 0;
66150 + else {
66151 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
66152 + return 1;
66153 + }
66154 +}
66155 +
66156 +extern int gr_acl_is_capable(const int cap);
66157 +
66158 +void
66159 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
66160 +{
66161 + struct acl_role_label *role = task->role;
66162 + struct acl_subject_label *subj = NULL;
66163 + struct acl_object_label *obj;
66164 + struct file *filp;
66165 + uid_t uid;
66166 + gid_t gid;
66167 +
66168 + if (unlikely(!(gr_status & GR_READY)))
66169 + return;
66170 +
66171 + uid = GR_GLOBAL_UID(kuid);
66172 + gid = GR_GLOBAL_GID(kgid);
66173 +
66174 + filp = task->exec_file;
66175 +
66176 + /* kernel process, we'll give them the kernel role */
66177 + if (unlikely(!filp)) {
66178 + task->role = kernel_role;
66179 + task->acl = kernel_role->root_label;
66180 + return;
66181 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
66182 + role = lookup_acl_role_label(task, uid, gid);
66183 +
66184 + /* don't change the role if we're not a privileged process */
66185 + if (role && task->role != role &&
66186 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
66187 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
66188 + return;
66189 +
66190 + /* perform subject lookup in possibly new role
66191 + we can use this result below in the case where role == task->role
66192 + */
66193 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
66194 +
66195 + /* if we changed uid/gid, but result in the same role
66196 + and are using inheritance, don't lose the inherited subject
66197 + if current subject is other than what normal lookup
66198 + would result in, we arrived via inheritance, don't
66199 + lose subject
66200 + */
66201 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
66202 + (subj == task->acl)))
66203 + task->acl = subj;
66204 +
66205 + task->role = role;
66206 +
66207 + task->is_writable = 0;
66208 +
66209 + /* ignore additional mmap checks for processes that are writable
66210 + by the default ACL */
66211 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66212 + if (unlikely(obj->mode & GR_WRITE))
66213 + task->is_writable = 1;
66214 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
66215 + if (unlikely(obj->mode & GR_WRITE))
66216 + task->is_writable = 1;
66217 +
66218 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66219 + 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);
66220 +#endif
66221 +
66222 + gr_set_proc_res(task);
66223 +
66224 + return;
66225 +}
66226 +
66227 +int
66228 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
66229 + const int unsafe_flags)
66230 +{
66231 + struct task_struct *task = current;
66232 + struct acl_subject_label *newacl;
66233 + struct acl_object_label *obj;
66234 + __u32 retmode;
66235 +
66236 + if (unlikely(!(gr_status & GR_READY)))
66237 + return 0;
66238 +
66239 + newacl = chk_subj_label(dentry, mnt, task->role);
66240 +
66241 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
66242 + did an exec
66243 + */
66244 + rcu_read_lock();
66245 + read_lock(&tasklist_lock);
66246 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
66247 + (task->parent->acl->mode & GR_POVERRIDE))) {
66248 + read_unlock(&tasklist_lock);
66249 + rcu_read_unlock();
66250 + goto skip_check;
66251 + }
66252 + read_unlock(&tasklist_lock);
66253 + rcu_read_unlock();
66254 +
66255 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
66256 + !(task->role->roletype & GR_ROLE_GOD) &&
66257 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
66258 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
66259 + if (unsafe_flags & LSM_UNSAFE_SHARE)
66260 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
66261 + else
66262 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
66263 + return -EACCES;
66264 + }
66265 +
66266 +skip_check:
66267 +
66268 + obj = chk_obj_label(dentry, mnt, task->acl);
66269 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
66270 +
66271 + if (!(task->acl->mode & GR_INHERITLEARN) &&
66272 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
66273 + if (obj->nested)
66274 + task->acl = obj->nested;
66275 + else
66276 + task->acl = newacl;
66277 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
66278 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
66279 +
66280 + task->is_writable = 0;
66281 +
66282 + /* ignore additional mmap checks for processes that are writable
66283 + by the default ACL */
66284 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
66285 + if (unlikely(obj->mode & GR_WRITE))
66286 + task->is_writable = 1;
66287 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
66288 + if (unlikely(obj->mode & GR_WRITE))
66289 + task->is_writable = 1;
66290 +
66291 + gr_set_proc_res(task);
66292 +
66293 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66294 + 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);
66295 +#endif
66296 + return 0;
66297 +}
66298 +
66299 +/* always called with valid inodev ptr */
66300 +static void
66301 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
66302 +{
66303 + struct acl_object_label *matchpo;
66304 + struct acl_subject_label *matchps;
66305 + struct acl_subject_label *subj;
66306 + struct acl_role_label *role;
66307 + unsigned int x;
66308 +
66309 + FOR_EACH_ROLE_START(role)
66310 + FOR_EACH_SUBJECT_START(role, subj, x)
66311 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
66312 + matchpo->mode |= GR_DELETED;
66313 + FOR_EACH_SUBJECT_END(subj,x)
66314 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
66315 + /* nested subjects aren't in the role's subj_hash table */
66316 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
66317 + matchpo->mode |= GR_DELETED;
66318 + FOR_EACH_NESTED_SUBJECT_END(subj)
66319 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
66320 + matchps->mode |= GR_DELETED;
66321 + FOR_EACH_ROLE_END(role)
66322 +
66323 + inodev->nentry->deleted = 1;
66324 +
66325 + return;
66326 +}
66327 +
66328 +void
66329 +gr_handle_delete(const ino_t ino, const dev_t dev)
66330 +{
66331 + struct inodev_entry *inodev;
66332 +
66333 + if (unlikely(!(gr_status & GR_READY)))
66334 + return;
66335 +
66336 + write_lock(&gr_inode_lock);
66337 + inodev = lookup_inodev_entry(ino, dev);
66338 + if (inodev != NULL)
66339 + do_handle_delete(inodev, ino, dev);
66340 + write_unlock(&gr_inode_lock);
66341 +
66342 + return;
66343 +}
66344 +
66345 +static void
66346 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
66347 + const ino_t newinode, const dev_t newdevice,
66348 + struct acl_subject_label *subj)
66349 +{
66350 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
66351 + struct acl_object_label *match;
66352 +
66353 + match = subj->obj_hash[index];
66354 +
66355 + while (match && (match->inode != oldinode ||
66356 + match->device != olddevice ||
66357 + !(match->mode & GR_DELETED)))
66358 + match = match->next;
66359 +
66360 + if (match && (match->inode == oldinode)
66361 + && (match->device == olddevice)
66362 + && (match->mode & GR_DELETED)) {
66363 + if (match->prev == NULL) {
66364 + subj->obj_hash[index] = match->next;
66365 + if (match->next != NULL)
66366 + match->next->prev = NULL;
66367 + } else {
66368 + match->prev->next = match->next;
66369 + if (match->next != NULL)
66370 + match->next->prev = match->prev;
66371 + }
66372 + match->prev = NULL;
66373 + match->next = NULL;
66374 + match->inode = newinode;
66375 + match->device = newdevice;
66376 + match->mode &= ~GR_DELETED;
66377 +
66378 + insert_acl_obj_label(match, subj);
66379 + }
66380 +
66381 + return;
66382 +}
66383 +
66384 +static void
66385 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
66386 + const ino_t newinode, const dev_t newdevice,
66387 + struct acl_role_label *role)
66388 +{
66389 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
66390 + struct acl_subject_label *match;
66391 +
66392 + match = role->subj_hash[index];
66393 +
66394 + while (match && (match->inode != oldinode ||
66395 + match->device != olddevice ||
66396 + !(match->mode & GR_DELETED)))
66397 + match = match->next;
66398 +
66399 + if (match && (match->inode == oldinode)
66400 + && (match->device == olddevice)
66401 + && (match->mode & GR_DELETED)) {
66402 + if (match->prev == NULL) {
66403 + role->subj_hash[index] = match->next;
66404 + if (match->next != NULL)
66405 + match->next->prev = NULL;
66406 + } else {
66407 + match->prev->next = match->next;
66408 + if (match->next != NULL)
66409 + match->next->prev = match->prev;
66410 + }
66411 + match->prev = NULL;
66412 + match->next = NULL;
66413 + match->inode = newinode;
66414 + match->device = newdevice;
66415 + match->mode &= ~GR_DELETED;
66416 +
66417 + insert_acl_subj_label(match, role);
66418 + }
66419 +
66420 + return;
66421 +}
66422 +
66423 +static void
66424 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
66425 + const ino_t newinode, const dev_t newdevice)
66426 +{
66427 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
66428 + struct inodev_entry *match;
66429 +
66430 + match = inodev_set.i_hash[index];
66431 +
66432 + while (match && (match->nentry->inode != oldinode ||
66433 + match->nentry->device != olddevice || !match->nentry->deleted))
66434 + match = match->next;
66435 +
66436 + if (match && (match->nentry->inode == oldinode)
66437 + && (match->nentry->device == olddevice) &&
66438 + match->nentry->deleted) {
66439 + if (match->prev == NULL) {
66440 + inodev_set.i_hash[index] = match->next;
66441 + if (match->next != NULL)
66442 + match->next->prev = NULL;
66443 + } else {
66444 + match->prev->next = match->next;
66445 + if (match->next != NULL)
66446 + match->next->prev = match->prev;
66447 + }
66448 + match->prev = NULL;
66449 + match->next = NULL;
66450 + match->nentry->inode = newinode;
66451 + match->nentry->device = newdevice;
66452 + match->nentry->deleted = 0;
66453 +
66454 + insert_inodev_entry(match);
66455 + }
66456 +
66457 + return;
66458 +}
66459 +
66460 +static void
66461 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
66462 +{
66463 + struct acl_subject_label *subj;
66464 + struct acl_role_label *role;
66465 + unsigned int x;
66466 +
66467 + FOR_EACH_ROLE_START(role)
66468 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
66469 +
66470 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
66471 + if ((subj->inode == ino) && (subj->device == dev)) {
66472 + subj->inode = ino;
66473 + subj->device = dev;
66474 + }
66475 + /* nested subjects aren't in the role's subj_hash table */
66476 + update_acl_obj_label(matchn->inode, matchn->device,
66477 + ino, dev, subj);
66478 + FOR_EACH_NESTED_SUBJECT_END(subj)
66479 + FOR_EACH_SUBJECT_START(role, subj, x)
66480 + update_acl_obj_label(matchn->inode, matchn->device,
66481 + ino, dev, subj);
66482 + FOR_EACH_SUBJECT_END(subj,x)
66483 + FOR_EACH_ROLE_END(role)
66484 +
66485 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
66486 +
66487 + return;
66488 +}
66489 +
66490 +static void
66491 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
66492 + const struct vfsmount *mnt)
66493 +{
66494 + ino_t ino = dentry->d_inode->i_ino;
66495 + dev_t dev = __get_dev(dentry);
66496 +
66497 + __do_handle_create(matchn, ino, dev);
66498 +
66499 + return;
66500 +}
66501 +
66502 +void
66503 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
66504 +{
66505 + struct name_entry *matchn;
66506 +
66507 + if (unlikely(!(gr_status & GR_READY)))
66508 + return;
66509 +
66510 + preempt_disable();
66511 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
66512 +
66513 + if (unlikely((unsigned long)matchn)) {
66514 + write_lock(&gr_inode_lock);
66515 + do_handle_create(matchn, dentry, mnt);
66516 + write_unlock(&gr_inode_lock);
66517 + }
66518 + preempt_enable();
66519 +
66520 + return;
66521 +}
66522 +
66523 +void
66524 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
66525 +{
66526 + struct name_entry *matchn;
66527 +
66528 + if (unlikely(!(gr_status & GR_READY)))
66529 + return;
66530 +
66531 + preempt_disable();
66532 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
66533 +
66534 + if (unlikely((unsigned long)matchn)) {
66535 + write_lock(&gr_inode_lock);
66536 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
66537 + write_unlock(&gr_inode_lock);
66538 + }
66539 + preempt_enable();
66540 +
66541 + return;
66542 +}
66543 +
66544 +void
66545 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
66546 + struct dentry *old_dentry,
66547 + struct dentry *new_dentry,
66548 + struct vfsmount *mnt, const __u8 replace)
66549 +{
66550 + struct name_entry *matchn;
66551 + struct inodev_entry *inodev;
66552 + struct inode *inode = new_dentry->d_inode;
66553 + ino_t old_ino = old_dentry->d_inode->i_ino;
66554 + dev_t old_dev = __get_dev(old_dentry);
66555 +
66556 + /* vfs_rename swaps the name and parent link for old_dentry and
66557 + new_dentry
66558 + at this point, old_dentry has the new name, parent link, and inode
66559 + for the renamed file
66560 + if a file is being replaced by a rename, new_dentry has the inode
66561 + and name for the replaced file
66562 + */
66563 +
66564 + if (unlikely(!(gr_status & GR_READY)))
66565 + return;
66566 +
66567 + preempt_disable();
66568 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
66569 +
66570 + /* we wouldn't have to check d_inode if it weren't for
66571 + NFS silly-renaming
66572 + */
66573 +
66574 + write_lock(&gr_inode_lock);
66575 + if (unlikely(replace && inode)) {
66576 + ino_t new_ino = inode->i_ino;
66577 + dev_t new_dev = __get_dev(new_dentry);
66578 +
66579 + inodev = lookup_inodev_entry(new_ino, new_dev);
66580 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
66581 + do_handle_delete(inodev, new_ino, new_dev);
66582 + }
66583 +
66584 + inodev = lookup_inodev_entry(old_ino, old_dev);
66585 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
66586 + do_handle_delete(inodev, old_ino, old_dev);
66587 +
66588 + if (unlikely((unsigned long)matchn))
66589 + do_handle_create(matchn, old_dentry, mnt);
66590 +
66591 + write_unlock(&gr_inode_lock);
66592 + preempt_enable();
66593 +
66594 + return;
66595 +}
66596 +
66597 +static int
66598 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
66599 + unsigned char **sum)
66600 +{
66601 + struct acl_role_label *r;
66602 + struct role_allowed_ip *ipp;
66603 + struct role_transition *trans;
66604 + unsigned int i;
66605 + int found = 0;
66606 + u32 curr_ip = current->signal->curr_ip;
66607 +
66608 + current->signal->saved_ip = curr_ip;
66609 +
66610 + /* check transition table */
66611 +
66612 + for (trans = current->role->transitions; trans; trans = trans->next) {
66613 + if (!strcmp(rolename, trans->rolename)) {
66614 + found = 1;
66615 + break;
66616 + }
66617 + }
66618 +
66619 + if (!found)
66620 + return 0;
66621 +
66622 + /* handle special roles that do not require authentication
66623 + and check ip */
66624 +
66625 + FOR_EACH_ROLE_START(r)
66626 + if (!strcmp(rolename, r->rolename) &&
66627 + (r->roletype & GR_ROLE_SPECIAL)) {
66628 + found = 0;
66629 + if (r->allowed_ips != NULL) {
66630 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
66631 + if ((ntohl(curr_ip) & ipp->netmask) ==
66632 + (ntohl(ipp->addr) & ipp->netmask))
66633 + found = 1;
66634 + }
66635 + } else
66636 + found = 2;
66637 + if (!found)
66638 + return 0;
66639 +
66640 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
66641 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
66642 + *salt = NULL;
66643 + *sum = NULL;
66644 + return 1;
66645 + }
66646 + }
66647 + FOR_EACH_ROLE_END(r)
66648 +
66649 + for (i = 0; i < num_sprole_pws; i++) {
66650 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
66651 + *salt = acl_special_roles[i]->salt;
66652 + *sum = acl_special_roles[i]->sum;
66653 + return 1;
66654 + }
66655 + }
66656 +
66657 + return 0;
66658 +}
66659 +
66660 +static void
66661 +assign_special_role(char *rolename)
66662 +{
66663 + struct acl_object_label *obj;
66664 + struct acl_role_label *r;
66665 + struct acl_role_label *assigned = NULL;
66666 + struct task_struct *tsk;
66667 + struct file *filp;
66668 +
66669 + FOR_EACH_ROLE_START(r)
66670 + if (!strcmp(rolename, r->rolename) &&
66671 + (r->roletype & GR_ROLE_SPECIAL)) {
66672 + assigned = r;
66673 + break;
66674 + }
66675 + FOR_EACH_ROLE_END(r)
66676 +
66677 + if (!assigned)
66678 + return;
66679 +
66680 + read_lock(&tasklist_lock);
66681 + read_lock(&grsec_exec_file_lock);
66682 +
66683 + tsk = current->real_parent;
66684 + if (tsk == NULL)
66685 + goto out_unlock;
66686 +
66687 + filp = tsk->exec_file;
66688 + if (filp == NULL)
66689 + goto out_unlock;
66690 +
66691 + tsk->is_writable = 0;
66692 +
66693 + tsk->acl_sp_role = 1;
66694 + tsk->acl_role_id = ++acl_sp_role_value;
66695 + tsk->role = assigned;
66696 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
66697 +
66698 + /* ignore additional mmap checks for processes that are writable
66699 + by the default ACL */
66700 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66701 + if (unlikely(obj->mode & GR_WRITE))
66702 + tsk->is_writable = 1;
66703 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
66704 + if (unlikely(obj->mode & GR_WRITE))
66705 + tsk->is_writable = 1;
66706 +
66707 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66708 + 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));
66709 +#endif
66710 +
66711 +out_unlock:
66712 + read_unlock(&grsec_exec_file_lock);
66713 + read_unlock(&tasklist_lock);
66714 + return;
66715 +}
66716 +
66717 +int gr_check_secure_terminal(struct task_struct *task)
66718 +{
66719 + struct task_struct *p, *p2, *p3;
66720 + struct files_struct *files;
66721 + struct fdtable *fdt;
66722 + struct file *our_file = NULL, *file;
66723 + int i;
66724 +
66725 + if (task->signal->tty == NULL)
66726 + return 1;
66727 +
66728 + files = get_files_struct(task);
66729 + if (files != NULL) {
66730 + rcu_read_lock();
66731 + fdt = files_fdtable(files);
66732 + for (i=0; i < fdt->max_fds; i++) {
66733 + file = fcheck_files(files, i);
66734 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
66735 + get_file(file);
66736 + our_file = file;
66737 + }
66738 + }
66739 + rcu_read_unlock();
66740 + put_files_struct(files);
66741 + }
66742 +
66743 + if (our_file == NULL)
66744 + return 1;
66745 +
66746 + read_lock(&tasklist_lock);
66747 + do_each_thread(p2, p) {
66748 + files = get_files_struct(p);
66749 + if (files == NULL ||
66750 + (p->signal && p->signal->tty == task->signal->tty)) {
66751 + if (files != NULL)
66752 + put_files_struct(files);
66753 + continue;
66754 + }
66755 + rcu_read_lock();
66756 + fdt = files_fdtable(files);
66757 + for (i=0; i < fdt->max_fds; i++) {
66758 + file = fcheck_files(files, i);
66759 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
66760 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
66761 + p3 = task;
66762 + while (task_pid_nr(p3) > 0) {
66763 + if (p3 == p)
66764 + break;
66765 + p3 = p3->real_parent;
66766 + }
66767 + if (p3 == p)
66768 + break;
66769 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
66770 + gr_handle_alertkill(p);
66771 + rcu_read_unlock();
66772 + put_files_struct(files);
66773 + read_unlock(&tasklist_lock);
66774 + fput(our_file);
66775 + return 0;
66776 + }
66777 + }
66778 + rcu_read_unlock();
66779 + put_files_struct(files);
66780 + } while_each_thread(p2, p);
66781 + read_unlock(&tasklist_lock);
66782 +
66783 + fput(our_file);
66784 + return 1;
66785 +}
66786 +
66787 +static int gr_rbac_disable(void *unused)
66788 +{
66789 + pax_open_kernel();
66790 + gr_status &= ~GR_READY;
66791 + pax_close_kernel();
66792 +
66793 + return 0;
66794 +}
66795 +
66796 +ssize_t
66797 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
66798 +{
66799 + struct gr_arg_wrapper uwrap;
66800 + unsigned char *sprole_salt = NULL;
66801 + unsigned char *sprole_sum = NULL;
66802 + int error = 0;
66803 + int error2 = 0;
66804 + size_t req_count = 0;
66805 +
66806 + mutex_lock(&gr_dev_mutex);
66807 +
66808 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
66809 + error = -EPERM;
66810 + goto out;
66811 + }
66812 +
66813 +#ifdef CONFIG_COMPAT
66814 + pax_open_kernel();
66815 + if (is_compat_task()) {
66816 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
66817 + copy_gr_arg = &copy_gr_arg_compat;
66818 + copy_acl_object_label = &copy_acl_object_label_compat;
66819 + copy_acl_subject_label = &copy_acl_subject_label_compat;
66820 + copy_acl_role_label = &copy_acl_role_label_compat;
66821 + copy_acl_ip_label = &copy_acl_ip_label_compat;
66822 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
66823 + copy_role_transition = &copy_role_transition_compat;
66824 + copy_sprole_pw = &copy_sprole_pw_compat;
66825 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
66826 + copy_pointer_from_array = &copy_pointer_from_array_compat;
66827 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
66828 + } else {
66829 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
66830 + copy_gr_arg = &copy_gr_arg_normal;
66831 + copy_acl_object_label = &copy_acl_object_label_normal;
66832 + copy_acl_subject_label = &copy_acl_subject_label_normal;
66833 + copy_acl_role_label = &copy_acl_role_label_normal;
66834 + copy_acl_ip_label = &copy_acl_ip_label_normal;
66835 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
66836 + copy_role_transition = &copy_role_transition_normal;
66837 + copy_sprole_pw = &copy_sprole_pw_normal;
66838 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
66839 + copy_pointer_from_array = &copy_pointer_from_array_normal;
66840 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
66841 + }
66842 + pax_close_kernel();
66843 +#endif
66844 +
66845 + req_count = get_gr_arg_wrapper_size();
66846 +
66847 + if (count != req_count) {
66848 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
66849 + error = -EINVAL;
66850 + goto out;
66851 + }
66852 +
66853 +
66854 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
66855 + gr_auth_expires = 0;
66856 + gr_auth_attempts = 0;
66857 + }
66858 +
66859 + error = copy_gr_arg_wrapper(buf, &uwrap);
66860 + if (error)
66861 + goto out;
66862 +
66863 + error = copy_gr_arg(uwrap.arg, gr_usermode);
66864 + if (error)
66865 + goto out;
66866 +
66867 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
66868 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
66869 + time_after(gr_auth_expires, get_seconds())) {
66870 + error = -EBUSY;
66871 + goto out;
66872 + }
66873 +
66874 + /* if non-root trying to do anything other than use a special role,
66875 + do not attempt authentication, do not count towards authentication
66876 + locking
66877 + */
66878 +
66879 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
66880 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
66881 + gr_is_global_nonroot(current_uid())) {
66882 + error = -EPERM;
66883 + goto out;
66884 + }
66885 +
66886 + /* ensure pw and special role name are null terminated */
66887 +
66888 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
66889 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
66890 +
66891 + /* Okay.
66892 + * We have our enough of the argument structure..(we have yet
66893 + * to copy_from_user the tables themselves) . Copy the tables
66894 + * only if we need them, i.e. for loading operations. */
66895 +
66896 + switch (gr_usermode->mode) {
66897 + case GR_STATUS:
66898 + if (gr_status & GR_READY) {
66899 + error = 1;
66900 + if (!gr_check_secure_terminal(current))
66901 + error = 3;
66902 + } else
66903 + error = 2;
66904 + goto out;
66905 + case GR_SHUTDOWN:
66906 + if ((gr_status & GR_READY)
66907 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
66908 + stop_machine(gr_rbac_disable, NULL, NULL);
66909 + free_variables();
66910 + memset(gr_usermode, 0, sizeof (struct gr_arg));
66911 + memset(gr_system_salt, 0, GR_SALT_LEN);
66912 + memset(gr_system_sum, 0, GR_SHA_LEN);
66913 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
66914 + } else if (gr_status & GR_READY) {
66915 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
66916 + error = -EPERM;
66917 + } else {
66918 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
66919 + error = -EAGAIN;
66920 + }
66921 + break;
66922 + case GR_ENABLE:
66923 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
66924 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
66925 + else {
66926 + if (gr_status & GR_READY)
66927 + error = -EAGAIN;
66928 + else
66929 + error = error2;
66930 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
66931 + }
66932 + break;
66933 + case GR_RELOAD:
66934 + if (!(gr_status & GR_READY)) {
66935 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
66936 + error = -EAGAIN;
66937 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
66938 + stop_machine(gr_rbac_disable, NULL, NULL);
66939 + free_variables();
66940 + error2 = gracl_init(gr_usermode);
66941 + if (!error2)
66942 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
66943 + else {
66944 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
66945 + error = error2;
66946 + }
66947 + } else {
66948 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
66949 + error = -EPERM;
66950 + }
66951 + break;
66952 + case GR_SEGVMOD:
66953 + if (unlikely(!(gr_status & GR_READY))) {
66954 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
66955 + error = -EAGAIN;
66956 + break;
66957 + }
66958 +
66959 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
66960 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
66961 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
66962 + struct acl_subject_label *segvacl;
66963 + segvacl =
66964 + lookup_acl_subj_label(gr_usermode->segv_inode,
66965 + gr_usermode->segv_device,
66966 + current->role);
66967 + if (segvacl) {
66968 + segvacl->crashes = 0;
66969 + segvacl->expires = 0;
66970 + }
66971 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
66972 + gr_remove_uid(gr_usermode->segv_uid);
66973 + }
66974 + } else {
66975 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
66976 + error = -EPERM;
66977 + }
66978 + break;
66979 + case GR_SPROLE:
66980 + case GR_SPROLEPAM:
66981 + if (unlikely(!(gr_status & GR_READY))) {
66982 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
66983 + error = -EAGAIN;
66984 + break;
66985 + }
66986 +
66987 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
66988 + current->role->expires = 0;
66989 + current->role->auth_attempts = 0;
66990 + }
66991 +
66992 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
66993 + time_after(current->role->expires, get_seconds())) {
66994 + error = -EBUSY;
66995 + goto out;
66996 + }
66997 +
66998 + if (lookup_special_role_auth
66999 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
67000 + && ((!sprole_salt && !sprole_sum)
67001 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
67002 + char *p = "";
67003 + assign_special_role(gr_usermode->sp_role);
67004 + read_lock(&tasklist_lock);
67005 + if (current->real_parent)
67006 + p = current->real_parent->role->rolename;
67007 + read_unlock(&tasklist_lock);
67008 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
67009 + p, acl_sp_role_value);
67010 + } else {
67011 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
67012 + error = -EPERM;
67013 + if(!(current->role->auth_attempts++))
67014 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
67015 +
67016 + goto out;
67017 + }
67018 + break;
67019 + case GR_UNSPROLE:
67020 + if (unlikely(!(gr_status & GR_READY))) {
67021 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
67022 + error = -EAGAIN;
67023 + break;
67024 + }
67025 +
67026 + if (current->role->roletype & GR_ROLE_SPECIAL) {
67027 + char *p = "";
67028 + int i = 0;
67029 +
67030 + read_lock(&tasklist_lock);
67031 + if (current->real_parent) {
67032 + p = current->real_parent->role->rolename;
67033 + i = current->real_parent->acl_role_id;
67034 + }
67035 + read_unlock(&tasklist_lock);
67036 +
67037 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
67038 + gr_set_acls(1);
67039 + } else {
67040 + error = -EPERM;
67041 + goto out;
67042 + }
67043 + break;
67044 + default:
67045 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
67046 + error = -EINVAL;
67047 + break;
67048 + }
67049 +
67050 + if (error != -EPERM)
67051 + goto out;
67052 +
67053 + if(!(gr_auth_attempts++))
67054 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
67055 +
67056 + out:
67057 + mutex_unlock(&gr_dev_mutex);
67058 +
67059 + if (!error)
67060 + error = req_count;
67061 +
67062 + return error;
67063 +}
67064 +
67065 +/* must be called with
67066 + rcu_read_lock();
67067 + read_lock(&tasklist_lock);
67068 + read_lock(&grsec_exec_file_lock);
67069 +*/
67070 +int gr_apply_subject_to_task(struct task_struct *task)
67071 +{
67072 + struct acl_object_label *obj;
67073 + char *tmpname;
67074 + struct acl_subject_label *tmpsubj;
67075 + struct file *filp;
67076 + struct name_entry *nmatch;
67077 +
67078 + filp = task->exec_file;
67079 + if (filp == NULL)
67080 + return 0;
67081 +
67082 + /* the following is to apply the correct subject
67083 + on binaries running when the RBAC system
67084 + is enabled, when the binaries have been
67085 + replaced or deleted since their execution
67086 + -----
67087 + when the RBAC system starts, the inode/dev
67088 + from exec_file will be one the RBAC system
67089 + is unaware of. It only knows the inode/dev
67090 + of the present file on disk, or the absence
67091 + of it.
67092 + */
67093 + preempt_disable();
67094 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
67095 +
67096 + nmatch = lookup_name_entry(tmpname);
67097 + preempt_enable();
67098 + tmpsubj = NULL;
67099 + if (nmatch) {
67100 + if (nmatch->deleted)
67101 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
67102 + else
67103 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
67104 + if (tmpsubj != NULL)
67105 + task->acl = tmpsubj;
67106 + }
67107 + if (tmpsubj == NULL)
67108 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
67109 + task->role);
67110 + if (task->acl) {
67111 + task->is_writable = 0;
67112 + /* ignore additional mmap checks for processes that are writable
67113 + by the default ACL */
67114 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
67115 + if (unlikely(obj->mode & GR_WRITE))
67116 + task->is_writable = 1;
67117 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
67118 + if (unlikely(obj->mode & GR_WRITE))
67119 + task->is_writable = 1;
67120 +
67121 + gr_set_proc_res(task);
67122 +
67123 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67124 + 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);
67125 +#endif
67126 + } else {
67127 + return 1;
67128 + }
67129 +
67130 + return 0;
67131 +}
67132 +
67133 +int
67134 +gr_set_acls(const int type)
67135 +{
67136 + struct task_struct *task, *task2;
67137 + struct acl_role_label *role = current->role;
67138 + __u16 acl_role_id = current->acl_role_id;
67139 + const struct cred *cred;
67140 + int ret;
67141 +
67142 + rcu_read_lock();
67143 + read_lock(&tasklist_lock);
67144 + read_lock(&grsec_exec_file_lock);
67145 + do_each_thread(task2, task) {
67146 + /* check to see if we're called from the exit handler,
67147 + if so, only replace ACLs that have inherited the admin
67148 + ACL */
67149 +
67150 + if (type && (task->role != role ||
67151 + task->acl_role_id != acl_role_id))
67152 + continue;
67153 +
67154 + task->acl_role_id = 0;
67155 + task->acl_sp_role = 0;
67156 +
67157 + if (task->exec_file) {
67158 + cred = __task_cred(task);
67159 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
67160 + ret = gr_apply_subject_to_task(task);
67161 + if (ret) {
67162 + read_unlock(&grsec_exec_file_lock);
67163 + read_unlock(&tasklist_lock);
67164 + rcu_read_unlock();
67165 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
67166 + return ret;
67167 + }
67168 + } else {
67169 + // it's a kernel process
67170 + task->role = kernel_role;
67171 + task->acl = kernel_role->root_label;
67172 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
67173 + task->acl->mode &= ~GR_PROCFIND;
67174 +#endif
67175 + }
67176 + } while_each_thread(task2, task);
67177 + read_unlock(&grsec_exec_file_lock);
67178 + read_unlock(&tasklist_lock);
67179 + rcu_read_unlock();
67180 +
67181 + return 0;
67182 +}
67183 +
67184 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
67185 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
67186 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
67187 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
67188 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
67189 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
67190 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
67191 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
67192 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
67193 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
67194 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
67195 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
67196 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
67197 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
67198 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
67199 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
67200 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
67201 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
67202 +};
67203 +
67204 +void
67205 +gr_learn_resource(const struct task_struct *task,
67206 + const int res, const unsigned long wanted, const int gt)
67207 +{
67208 + struct acl_subject_label *acl;
67209 + const struct cred *cred;
67210 +
67211 + if (unlikely((gr_status & GR_READY) &&
67212 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
67213 + goto skip_reslog;
67214 +
67215 + gr_log_resource(task, res, wanted, gt);
67216 +skip_reslog:
67217 +
67218 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
67219 + return;
67220 +
67221 + acl = task->acl;
67222 +
67223 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
67224 + !(acl->resmask & (1U << (unsigned short) res))))
67225 + return;
67226 +
67227 + if (wanted >= acl->res[res].rlim_cur) {
67228 + unsigned long res_add;
67229 +
67230 + res_add = wanted + res_learn_bumps[res];
67231 +
67232 + acl->res[res].rlim_cur = res_add;
67233 +
67234 + if (wanted > acl->res[res].rlim_max)
67235 + acl->res[res].rlim_max = res_add;
67236 +
67237 + /* only log the subject filename, since resource logging is supported for
67238 + single-subject learning only */
67239 + rcu_read_lock();
67240 + cred = __task_cred(task);
67241 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
67242 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
67243 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
67244 + "", (unsigned long) res, &task->signal->saved_ip);
67245 + rcu_read_unlock();
67246 + }
67247 +
67248 + return;
67249 +}
67250 +EXPORT_SYMBOL(gr_learn_resource);
67251 +#endif
67252 +
67253 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
67254 +void
67255 +pax_set_initial_flags(struct linux_binprm *bprm)
67256 +{
67257 + struct task_struct *task = current;
67258 + struct acl_subject_label *proc;
67259 + unsigned long flags;
67260 +
67261 + if (unlikely(!(gr_status & GR_READY)))
67262 + return;
67263 +
67264 + flags = pax_get_flags(task);
67265 +
67266 + proc = task->acl;
67267 +
67268 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
67269 + flags &= ~MF_PAX_PAGEEXEC;
67270 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
67271 + flags &= ~MF_PAX_SEGMEXEC;
67272 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
67273 + flags &= ~MF_PAX_RANDMMAP;
67274 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
67275 + flags &= ~MF_PAX_EMUTRAMP;
67276 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
67277 + flags &= ~MF_PAX_MPROTECT;
67278 +
67279 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
67280 + flags |= MF_PAX_PAGEEXEC;
67281 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
67282 + flags |= MF_PAX_SEGMEXEC;
67283 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
67284 + flags |= MF_PAX_RANDMMAP;
67285 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
67286 + flags |= MF_PAX_EMUTRAMP;
67287 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
67288 + flags |= MF_PAX_MPROTECT;
67289 +
67290 + pax_set_flags(task, flags);
67291 +
67292 + return;
67293 +}
67294 +#endif
67295 +
67296 +int
67297 +gr_handle_proc_ptrace(struct task_struct *task)
67298 +{
67299 + struct file *filp;
67300 + struct task_struct *tmp = task;
67301 + struct task_struct *curtemp = current;
67302 + __u32 retmode;
67303 +
67304 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
67305 + if (unlikely(!(gr_status & GR_READY)))
67306 + return 0;
67307 +#endif
67308 +
67309 + read_lock(&tasklist_lock);
67310 + read_lock(&grsec_exec_file_lock);
67311 + filp = task->exec_file;
67312 +
67313 + while (task_pid_nr(tmp) > 0) {
67314 + if (tmp == curtemp)
67315 + break;
67316 + tmp = tmp->real_parent;
67317 + }
67318 +
67319 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
67320 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
67321 + read_unlock(&grsec_exec_file_lock);
67322 + read_unlock(&tasklist_lock);
67323 + return 1;
67324 + }
67325 +
67326 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67327 + if (!(gr_status & GR_READY)) {
67328 + read_unlock(&grsec_exec_file_lock);
67329 + read_unlock(&tasklist_lock);
67330 + return 0;
67331 + }
67332 +#endif
67333 +
67334 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
67335 + read_unlock(&grsec_exec_file_lock);
67336 + read_unlock(&tasklist_lock);
67337 +
67338 + if (retmode & GR_NOPTRACE)
67339 + return 1;
67340 +
67341 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
67342 + && (current->acl != task->acl || (current->acl != current->role->root_label
67343 + && task_pid_nr(current) != task_pid_nr(task))))
67344 + return 1;
67345 +
67346 + return 0;
67347 +}
67348 +
67349 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
67350 +{
67351 + if (unlikely(!(gr_status & GR_READY)))
67352 + return;
67353 +
67354 + if (!(current->role->roletype & GR_ROLE_GOD))
67355 + return;
67356 +
67357 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
67358 + p->role->rolename, gr_task_roletype_to_char(p),
67359 + p->acl->filename);
67360 +}
67361 +
67362 +int
67363 +gr_handle_ptrace(struct task_struct *task, const long request)
67364 +{
67365 + struct task_struct *tmp = task;
67366 + struct task_struct *curtemp = current;
67367 + __u32 retmode;
67368 +
67369 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
67370 + if (unlikely(!(gr_status & GR_READY)))
67371 + return 0;
67372 +#endif
67373 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
67374 + read_lock(&tasklist_lock);
67375 + while (task_pid_nr(tmp) > 0) {
67376 + if (tmp == curtemp)
67377 + break;
67378 + tmp = tmp->real_parent;
67379 + }
67380 +
67381 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
67382 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
67383 + read_unlock(&tasklist_lock);
67384 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
67385 + return 1;
67386 + }
67387 + read_unlock(&tasklist_lock);
67388 + }
67389 +
67390 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67391 + if (!(gr_status & GR_READY))
67392 + return 0;
67393 +#endif
67394 +
67395 + read_lock(&grsec_exec_file_lock);
67396 + if (unlikely(!task->exec_file)) {
67397 + read_unlock(&grsec_exec_file_lock);
67398 + return 0;
67399 + }
67400 +
67401 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
67402 + read_unlock(&grsec_exec_file_lock);
67403 +
67404 + if (retmode & GR_NOPTRACE) {
67405 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
67406 + return 1;
67407 + }
67408 +
67409 + if (retmode & GR_PTRACERD) {
67410 + switch (request) {
67411 + case PTRACE_SEIZE:
67412 + case PTRACE_POKETEXT:
67413 + case PTRACE_POKEDATA:
67414 + case PTRACE_POKEUSR:
67415 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
67416 + case PTRACE_SETREGS:
67417 + case PTRACE_SETFPREGS:
67418 +#endif
67419 +#ifdef CONFIG_X86
67420 + case PTRACE_SETFPXREGS:
67421 +#endif
67422 +#ifdef CONFIG_ALTIVEC
67423 + case PTRACE_SETVRREGS:
67424 +#endif
67425 + return 1;
67426 + default:
67427 + return 0;
67428 + }
67429 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
67430 + !(current->role->roletype & GR_ROLE_GOD) &&
67431 + (current->acl != task->acl)) {
67432 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
67433 + return 1;
67434 + }
67435 +
67436 + return 0;
67437 +}
67438 +
67439 +static int is_writable_mmap(const struct file *filp)
67440 +{
67441 + struct task_struct *task = current;
67442 + struct acl_object_label *obj, *obj2;
67443 +
67444 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
67445 + !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))) {
67446 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
67447 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
67448 + task->role->root_label);
67449 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
67450 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
67451 + return 1;
67452 + }
67453 + }
67454 + return 0;
67455 +}
67456 +
67457 +int
67458 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
67459 +{
67460 + __u32 mode;
67461 +
67462 + if (unlikely(!file || !(prot & PROT_EXEC)))
67463 + return 1;
67464 +
67465 + if (is_writable_mmap(file))
67466 + return 0;
67467 +
67468 + mode =
67469 + gr_search_file(file->f_path.dentry,
67470 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
67471 + file->f_path.mnt);
67472 +
67473 + if (!gr_tpe_allow(file))
67474 + return 0;
67475 +
67476 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
67477 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67478 + return 0;
67479 + } else if (unlikely(!(mode & GR_EXEC))) {
67480 + return 0;
67481 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
67482 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67483 + return 1;
67484 + }
67485 +
67486 + return 1;
67487 +}
67488 +
67489 +int
67490 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
67491 +{
67492 + __u32 mode;
67493 +
67494 + if (unlikely(!file || !(prot & PROT_EXEC)))
67495 + return 1;
67496 +
67497 + if (is_writable_mmap(file))
67498 + return 0;
67499 +
67500 + mode =
67501 + gr_search_file(file->f_path.dentry,
67502 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
67503 + file->f_path.mnt);
67504 +
67505 + if (!gr_tpe_allow(file))
67506 + return 0;
67507 +
67508 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
67509 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67510 + return 0;
67511 + } else if (unlikely(!(mode & GR_EXEC))) {
67512 + return 0;
67513 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
67514 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67515 + return 1;
67516 + }
67517 +
67518 + return 1;
67519 +}
67520 +
67521 +void
67522 +gr_acl_handle_psacct(struct task_struct *task, const long code)
67523 +{
67524 + unsigned long runtime;
67525 + unsigned long cputime;
67526 + unsigned int wday, cday;
67527 + __u8 whr, chr;
67528 + __u8 wmin, cmin;
67529 + __u8 wsec, csec;
67530 + struct timespec timeval;
67531 +
67532 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
67533 + !(task->acl->mode & GR_PROCACCT)))
67534 + return;
67535 +
67536 + do_posix_clock_monotonic_gettime(&timeval);
67537 + runtime = timeval.tv_sec - task->start_time.tv_sec;
67538 + wday = runtime / (3600 * 24);
67539 + runtime -= wday * (3600 * 24);
67540 + whr = runtime / 3600;
67541 + runtime -= whr * 3600;
67542 + wmin = runtime / 60;
67543 + runtime -= wmin * 60;
67544 + wsec = runtime;
67545 +
67546 + cputime = (task->utime + task->stime) / HZ;
67547 + cday = cputime / (3600 * 24);
67548 + cputime -= cday * (3600 * 24);
67549 + chr = cputime / 3600;
67550 + cputime -= chr * 3600;
67551 + cmin = cputime / 60;
67552 + cputime -= cmin * 60;
67553 + csec = cputime;
67554 +
67555 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
67556 +
67557 + return;
67558 +}
67559 +
67560 +void gr_set_kernel_label(struct task_struct *task)
67561 +{
67562 + if (gr_status & GR_READY) {
67563 + task->role = kernel_role;
67564 + task->acl = kernel_role->root_label;
67565 + }
67566 + return;
67567 +}
67568 +
67569 +#ifdef CONFIG_TASKSTATS
67570 +int gr_is_taskstats_denied(int pid)
67571 +{
67572 + struct task_struct *task;
67573 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67574 + const struct cred *cred;
67575 +#endif
67576 + int ret = 0;
67577 +
67578 + /* restrict taskstats viewing to un-chrooted root users
67579 + who have the 'view' subject flag if the RBAC system is enabled
67580 + */
67581 +
67582 + rcu_read_lock();
67583 + read_lock(&tasklist_lock);
67584 + task = find_task_by_vpid(pid);
67585 + if (task) {
67586 +#ifdef CONFIG_GRKERNSEC_CHROOT
67587 + if (proc_is_chrooted(task))
67588 + ret = -EACCES;
67589 +#endif
67590 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67591 + cred = __task_cred(task);
67592 +#ifdef CONFIG_GRKERNSEC_PROC_USER
67593 + if (gr_is_global_nonroot(cred->uid))
67594 + ret = -EACCES;
67595 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67596 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
67597 + ret = -EACCES;
67598 +#endif
67599 +#endif
67600 + if (gr_status & GR_READY) {
67601 + if (!(task->acl->mode & GR_VIEW))
67602 + ret = -EACCES;
67603 + }
67604 + } else
67605 + ret = -ENOENT;
67606 +
67607 + read_unlock(&tasklist_lock);
67608 + rcu_read_unlock();
67609 +
67610 + return ret;
67611 +}
67612 +#endif
67613 +
67614 +/* AUXV entries are filled via a descendant of search_binary_handler
67615 + after we've already applied the subject for the target
67616 +*/
67617 +int gr_acl_enable_at_secure(void)
67618 +{
67619 + if (unlikely(!(gr_status & GR_READY)))
67620 + return 0;
67621 +
67622 + if (current->acl->mode & GR_ATSECURE)
67623 + return 1;
67624 +
67625 + return 0;
67626 +}
67627 +
67628 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
67629 +{
67630 + struct task_struct *task = current;
67631 + struct dentry *dentry = file->f_path.dentry;
67632 + struct vfsmount *mnt = file->f_path.mnt;
67633 + struct acl_object_label *obj, *tmp;
67634 + struct acl_subject_label *subj;
67635 + unsigned int bufsize;
67636 + int is_not_root;
67637 + char *path;
67638 + dev_t dev = __get_dev(dentry);
67639 +
67640 + if (unlikely(!(gr_status & GR_READY)))
67641 + return 1;
67642 +
67643 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
67644 + return 1;
67645 +
67646 + /* ignore Eric Biederman */
67647 + if (IS_PRIVATE(dentry->d_inode))
67648 + return 1;
67649 +
67650 + subj = task->acl;
67651 + read_lock(&gr_inode_lock);
67652 + do {
67653 + obj = lookup_acl_obj_label(ino, dev, subj);
67654 + if (obj != NULL) {
67655 + read_unlock(&gr_inode_lock);
67656 + return (obj->mode & GR_FIND) ? 1 : 0;
67657 + }
67658 + } while ((subj = subj->parent_subject));
67659 + read_unlock(&gr_inode_lock);
67660 +
67661 + /* this is purely an optimization since we're looking for an object
67662 + for the directory we're doing a readdir on
67663 + if it's possible for any globbed object to match the entry we're
67664 + filling into the directory, then the object we find here will be
67665 + an anchor point with attached globbed objects
67666 + */
67667 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
67668 + if (obj->globbed == NULL)
67669 + return (obj->mode & GR_FIND) ? 1 : 0;
67670 +
67671 + is_not_root = ((obj->filename[0] == '/') &&
67672 + (obj->filename[1] == '\0')) ? 0 : 1;
67673 + bufsize = PAGE_SIZE - namelen - is_not_root;
67674 +
67675 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
67676 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
67677 + return 1;
67678 +
67679 + preempt_disable();
67680 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
67681 + bufsize);
67682 +
67683 + bufsize = strlen(path);
67684 +
67685 + /* if base is "/", don't append an additional slash */
67686 + if (is_not_root)
67687 + *(path + bufsize) = '/';
67688 + memcpy(path + bufsize + is_not_root, name, namelen);
67689 + *(path + bufsize + namelen + is_not_root) = '\0';
67690 +
67691 + tmp = obj->globbed;
67692 + while (tmp) {
67693 + if (!glob_match(tmp->filename, path)) {
67694 + preempt_enable();
67695 + return (tmp->mode & GR_FIND) ? 1 : 0;
67696 + }
67697 + tmp = tmp->next;
67698 + }
67699 + preempt_enable();
67700 + return (obj->mode & GR_FIND) ? 1 : 0;
67701 +}
67702 +
67703 +void gr_put_exec_file(struct task_struct *task)
67704 +{
67705 + struct file *filp;
67706 +
67707 + write_lock(&grsec_exec_file_lock);
67708 + filp = task->exec_file;
67709 + task->exec_file = NULL;
67710 + write_unlock(&grsec_exec_file_lock);
67711 +
67712 + if (filp)
67713 + fput(filp);
67714 +
67715 + return;
67716 +}
67717 +
67718 +
67719 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
67720 +EXPORT_SYMBOL(gr_acl_is_enabled);
67721 +#endif
67722 +EXPORT_SYMBOL(gr_set_kernel_label);
67723 +#ifdef CONFIG_SECURITY
67724 +EXPORT_SYMBOL(gr_check_user_change);
67725 +EXPORT_SYMBOL(gr_check_group_change);
67726 +#endif
67727 +
67728 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
67729 new file mode 100644
67730 index 0000000..34fefda
67731 --- /dev/null
67732 +++ b/grsecurity/gracl_alloc.c
67733 @@ -0,0 +1,105 @@
67734 +#include <linux/kernel.h>
67735 +#include <linux/mm.h>
67736 +#include <linux/slab.h>
67737 +#include <linux/vmalloc.h>
67738 +#include <linux/gracl.h>
67739 +#include <linux/grsecurity.h>
67740 +
67741 +static unsigned long alloc_stack_next = 1;
67742 +static unsigned long alloc_stack_size = 1;
67743 +static void **alloc_stack;
67744 +
67745 +static __inline__ int
67746 +alloc_pop(void)
67747 +{
67748 + if (alloc_stack_next == 1)
67749 + return 0;
67750 +
67751 + kfree(alloc_stack[alloc_stack_next - 2]);
67752 +
67753 + alloc_stack_next--;
67754 +
67755 + return 1;
67756 +}
67757 +
67758 +static __inline__ int
67759 +alloc_push(void *buf)
67760 +{
67761 + if (alloc_stack_next >= alloc_stack_size)
67762 + return 1;
67763 +
67764 + alloc_stack[alloc_stack_next - 1] = buf;
67765 +
67766 + alloc_stack_next++;
67767 +
67768 + return 0;
67769 +}
67770 +
67771 +void *
67772 +acl_alloc(unsigned long len)
67773 +{
67774 + void *ret = NULL;
67775 +
67776 + if (!len || len > PAGE_SIZE)
67777 + goto out;
67778 +
67779 + ret = kmalloc(len, GFP_KERNEL);
67780 +
67781 + if (ret) {
67782 + if (alloc_push(ret)) {
67783 + kfree(ret);
67784 + ret = NULL;
67785 + }
67786 + }
67787 +
67788 +out:
67789 + return ret;
67790 +}
67791 +
67792 +void *
67793 +acl_alloc_num(unsigned long num, unsigned long len)
67794 +{
67795 + if (!len || (num > (PAGE_SIZE / len)))
67796 + return NULL;
67797 +
67798 + return acl_alloc(num * len);
67799 +}
67800 +
67801 +void
67802 +acl_free_all(void)
67803 +{
67804 + if (gr_acl_is_enabled() || !alloc_stack)
67805 + return;
67806 +
67807 + while (alloc_pop()) ;
67808 +
67809 + if (alloc_stack) {
67810 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
67811 + kfree(alloc_stack);
67812 + else
67813 + vfree(alloc_stack);
67814 + }
67815 +
67816 + alloc_stack = NULL;
67817 + alloc_stack_size = 1;
67818 + alloc_stack_next = 1;
67819 +
67820 + return;
67821 +}
67822 +
67823 +int
67824 +acl_alloc_stack_init(unsigned long size)
67825 +{
67826 + if ((size * sizeof (void *)) <= PAGE_SIZE)
67827 + alloc_stack =
67828 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
67829 + else
67830 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
67831 +
67832 + alloc_stack_size = size;
67833 +
67834 + if (!alloc_stack)
67835 + return 0;
67836 + else
67837 + return 1;
67838 +}
67839 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
67840 new file mode 100644
67841 index 0000000..bdd51ea
67842 --- /dev/null
67843 +++ b/grsecurity/gracl_cap.c
67844 @@ -0,0 +1,110 @@
67845 +#include <linux/kernel.h>
67846 +#include <linux/module.h>
67847 +#include <linux/sched.h>
67848 +#include <linux/gracl.h>
67849 +#include <linux/grsecurity.h>
67850 +#include <linux/grinternal.h>
67851 +
67852 +extern const char *captab_log[];
67853 +extern int captab_log_entries;
67854 +
67855 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
67856 +{
67857 + struct acl_subject_label *curracl;
67858 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
67859 + kernel_cap_t cap_audit = __cap_empty_set;
67860 +
67861 + if (!gr_acl_is_enabled())
67862 + return 1;
67863 +
67864 + curracl = task->acl;
67865 +
67866 + cap_drop = curracl->cap_lower;
67867 + cap_mask = curracl->cap_mask;
67868 + cap_audit = curracl->cap_invert_audit;
67869 +
67870 + while ((curracl = curracl->parent_subject)) {
67871 + /* if the cap isn't specified in the current computed mask but is specified in the
67872 + current level subject, and is lowered in the current level subject, then add
67873 + it to the set of dropped capabilities
67874 + otherwise, add the current level subject's mask to the current computed mask
67875 + */
67876 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
67877 + cap_raise(cap_mask, cap);
67878 + if (cap_raised(curracl->cap_lower, cap))
67879 + cap_raise(cap_drop, cap);
67880 + if (cap_raised(curracl->cap_invert_audit, cap))
67881 + cap_raise(cap_audit, cap);
67882 + }
67883 + }
67884 +
67885 + if (!cap_raised(cap_drop, cap)) {
67886 + if (cap_raised(cap_audit, cap))
67887 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
67888 + return 1;
67889 + }
67890 +
67891 + curracl = task->acl;
67892 +
67893 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
67894 + && cap_raised(cred->cap_effective, cap)) {
67895 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
67896 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
67897 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
67898 + gr_to_filename(task->exec_file->f_path.dentry,
67899 + task->exec_file->f_path.mnt) : curracl->filename,
67900 + curracl->filename, 0UL,
67901 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
67902 + return 1;
67903 + }
67904 +
67905 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
67906 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
67907 +
67908 + return 0;
67909 +}
67910 +
67911 +int
67912 +gr_acl_is_capable(const int cap)
67913 +{
67914 + return gr_task_acl_is_capable(current, current_cred(), cap);
67915 +}
67916 +
67917 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
67918 +{
67919 + struct acl_subject_label *curracl;
67920 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
67921 +
67922 + if (!gr_acl_is_enabled())
67923 + return 1;
67924 +
67925 + curracl = task->acl;
67926 +
67927 + cap_drop = curracl->cap_lower;
67928 + cap_mask = curracl->cap_mask;
67929 +
67930 + while ((curracl = curracl->parent_subject)) {
67931 + /* if the cap isn't specified in the current computed mask but is specified in the
67932 + current level subject, and is lowered in the current level subject, then add
67933 + it to the set of dropped capabilities
67934 + otherwise, add the current level subject's mask to the current computed mask
67935 + */
67936 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
67937 + cap_raise(cap_mask, cap);
67938 + if (cap_raised(curracl->cap_lower, cap))
67939 + cap_raise(cap_drop, cap);
67940 + }
67941 + }
67942 +
67943 + if (!cap_raised(cap_drop, cap))
67944 + return 1;
67945 +
67946 + return 0;
67947 +}
67948 +
67949 +int
67950 +gr_acl_is_capable_nolog(const int cap)
67951 +{
67952 + return gr_task_acl_is_capable_nolog(current, cap);
67953 +}
67954 +
67955 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
67956 new file mode 100644
67957 index 0000000..a43dd06
67958 --- /dev/null
67959 +++ b/grsecurity/gracl_compat.c
67960 @@ -0,0 +1,269 @@
67961 +#include <linux/kernel.h>
67962 +#include <linux/gracl.h>
67963 +#include <linux/compat.h>
67964 +#include <linux/gracl_compat.h>
67965 +
67966 +#include <asm/uaccess.h>
67967 +
67968 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
67969 +{
67970 + struct gr_arg_wrapper_compat uwrapcompat;
67971 +
67972 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
67973 + return -EFAULT;
67974 +
67975 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
67976 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
67977 + return -EINVAL;
67978 +
67979 + uwrap->arg = compat_ptr(uwrapcompat.arg);
67980 + uwrap->version = uwrapcompat.version;
67981 + uwrap->size = sizeof(struct gr_arg);
67982 +
67983 + return 0;
67984 +}
67985 +
67986 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
67987 +{
67988 + struct gr_arg_compat argcompat;
67989 +
67990 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
67991 + return -EFAULT;
67992 +
67993 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
67994 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
67995 + arg->role_db.num_roles = argcompat.role_db.num_roles;
67996 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
67997 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
67998 + arg->role_db.num_objects = argcompat.role_db.num_objects;
67999 +
68000 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
68001 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
68002 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
68003 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
68004 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
68005 + arg->segv_device = argcompat.segv_device;
68006 + arg->segv_inode = argcompat.segv_inode;
68007 + arg->segv_uid = argcompat.segv_uid;
68008 + arg->num_sprole_pws = argcompat.num_sprole_pws;
68009 + arg->mode = argcompat.mode;
68010 +
68011 + return 0;
68012 +}
68013 +
68014 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
68015 +{
68016 + struct acl_object_label_compat objcompat;
68017 +
68018 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
68019 + return -EFAULT;
68020 +
68021 + obj->filename = compat_ptr(objcompat.filename);
68022 + obj->inode = objcompat.inode;
68023 + obj->device = objcompat.device;
68024 + obj->mode = objcompat.mode;
68025 +
68026 + obj->nested = compat_ptr(objcompat.nested);
68027 + obj->globbed = compat_ptr(objcompat.globbed);
68028 +
68029 + obj->prev = compat_ptr(objcompat.prev);
68030 + obj->next = compat_ptr(objcompat.next);
68031 +
68032 + return 0;
68033 +}
68034 +
68035 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
68036 +{
68037 + unsigned int i;
68038 + struct acl_subject_label_compat subjcompat;
68039 +
68040 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
68041 + return -EFAULT;
68042 +
68043 + subj->filename = compat_ptr(subjcompat.filename);
68044 + subj->inode = subjcompat.inode;
68045 + subj->device = subjcompat.device;
68046 + subj->mode = subjcompat.mode;
68047 + subj->cap_mask = subjcompat.cap_mask;
68048 + subj->cap_lower = subjcompat.cap_lower;
68049 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
68050 +
68051 + for (i = 0; i < GR_NLIMITS; i++) {
68052 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
68053 + subj->res[i].rlim_cur = RLIM_INFINITY;
68054 + else
68055 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
68056 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
68057 + subj->res[i].rlim_max = RLIM_INFINITY;
68058 + else
68059 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
68060 + }
68061 + subj->resmask = subjcompat.resmask;
68062 +
68063 + subj->user_trans_type = subjcompat.user_trans_type;
68064 + subj->group_trans_type = subjcompat.group_trans_type;
68065 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
68066 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
68067 + subj->user_trans_num = subjcompat.user_trans_num;
68068 + subj->group_trans_num = subjcompat.group_trans_num;
68069 +
68070 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
68071 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
68072 + subj->ip_type = subjcompat.ip_type;
68073 + subj->ips = compat_ptr(subjcompat.ips);
68074 + subj->ip_num = subjcompat.ip_num;
68075 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
68076 +
68077 + subj->crashes = subjcompat.crashes;
68078 + subj->expires = subjcompat.expires;
68079 +
68080 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
68081 + subj->hash = compat_ptr(subjcompat.hash);
68082 + subj->prev = compat_ptr(subjcompat.prev);
68083 + subj->next = compat_ptr(subjcompat.next);
68084 +
68085 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
68086 + subj->obj_hash_size = subjcompat.obj_hash_size;
68087 + subj->pax_flags = subjcompat.pax_flags;
68088 +
68089 + return 0;
68090 +}
68091 +
68092 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
68093 +{
68094 + struct acl_role_label_compat rolecompat;
68095 +
68096 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
68097 + return -EFAULT;
68098 +
68099 + role->rolename = compat_ptr(rolecompat.rolename);
68100 + role->uidgid = rolecompat.uidgid;
68101 + role->roletype = rolecompat.roletype;
68102 +
68103 + role->auth_attempts = rolecompat.auth_attempts;
68104 + role->expires = rolecompat.expires;
68105 +
68106 + role->root_label = compat_ptr(rolecompat.root_label);
68107 + role->hash = compat_ptr(rolecompat.hash);
68108 +
68109 + role->prev = compat_ptr(rolecompat.prev);
68110 + role->next = compat_ptr(rolecompat.next);
68111 +
68112 + role->transitions = compat_ptr(rolecompat.transitions);
68113 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
68114 + role->domain_children = compat_ptr(rolecompat.domain_children);
68115 + role->domain_child_num = rolecompat.domain_child_num;
68116 +
68117 + role->umask = rolecompat.umask;
68118 +
68119 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
68120 + role->subj_hash_size = rolecompat.subj_hash_size;
68121 +
68122 + return 0;
68123 +}
68124 +
68125 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
68126 +{
68127 + struct role_allowed_ip_compat roleip_compat;
68128 +
68129 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
68130 + return -EFAULT;
68131 +
68132 + roleip->addr = roleip_compat.addr;
68133 + roleip->netmask = roleip_compat.netmask;
68134 +
68135 + roleip->prev = compat_ptr(roleip_compat.prev);
68136 + roleip->next = compat_ptr(roleip_compat.next);
68137 +
68138 + return 0;
68139 +}
68140 +
68141 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
68142 +{
68143 + struct role_transition_compat trans_compat;
68144 +
68145 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
68146 + return -EFAULT;
68147 +
68148 + trans->rolename = compat_ptr(trans_compat.rolename);
68149 +
68150 + trans->prev = compat_ptr(trans_compat.prev);
68151 + trans->next = compat_ptr(trans_compat.next);
68152 +
68153 + return 0;
68154 +
68155 +}
68156 +
68157 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
68158 +{
68159 + struct gr_hash_struct_compat hash_compat;
68160 +
68161 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
68162 + return -EFAULT;
68163 +
68164 + hash->table = compat_ptr(hash_compat.table);
68165 + hash->nametable = compat_ptr(hash_compat.nametable);
68166 + hash->first = compat_ptr(hash_compat.first);
68167 +
68168 + hash->table_size = hash_compat.table_size;
68169 + hash->used_size = hash_compat.used_size;
68170 +
68171 + hash->type = hash_compat.type;
68172 +
68173 + return 0;
68174 +}
68175 +
68176 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
68177 +{
68178 + compat_uptr_t ptrcompat;
68179 +
68180 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
68181 + return -EFAULT;
68182 +
68183 + *(void **)ptr = compat_ptr(ptrcompat);
68184 +
68185 + return 0;
68186 +}
68187 +
68188 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
68189 +{
68190 + struct acl_ip_label_compat ip_compat;
68191 +
68192 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
68193 + return -EFAULT;
68194 +
68195 + ip->iface = compat_ptr(ip_compat.iface);
68196 + ip->addr = ip_compat.addr;
68197 + ip->netmask = ip_compat.netmask;
68198 + ip->low = ip_compat.low;
68199 + ip->high = ip_compat.high;
68200 + ip->mode = ip_compat.mode;
68201 + ip->type = ip_compat.type;
68202 +
68203 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
68204 +
68205 + ip->prev = compat_ptr(ip_compat.prev);
68206 + ip->next = compat_ptr(ip_compat.next);
68207 +
68208 + return 0;
68209 +}
68210 +
68211 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
68212 +{
68213 + struct sprole_pw_compat pw_compat;
68214 +
68215 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
68216 + return -EFAULT;
68217 +
68218 + pw->rolename = compat_ptr(pw_compat.rolename);
68219 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
68220 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
68221 +
68222 + return 0;
68223 +}
68224 +
68225 +size_t get_gr_arg_wrapper_size_compat(void)
68226 +{
68227 + return sizeof(struct gr_arg_wrapper_compat);
68228 +}
68229 +
68230 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
68231 new file mode 100644
68232 index 0000000..a340c17
68233 --- /dev/null
68234 +++ b/grsecurity/gracl_fs.c
68235 @@ -0,0 +1,431 @@
68236 +#include <linux/kernel.h>
68237 +#include <linux/sched.h>
68238 +#include <linux/types.h>
68239 +#include <linux/fs.h>
68240 +#include <linux/file.h>
68241 +#include <linux/stat.h>
68242 +#include <linux/grsecurity.h>
68243 +#include <linux/grinternal.h>
68244 +#include <linux/gracl.h>
68245 +
68246 +umode_t
68247 +gr_acl_umask(void)
68248 +{
68249 + if (unlikely(!gr_acl_is_enabled()))
68250 + return 0;
68251 +
68252 + return current->role->umask;
68253 +}
68254 +
68255 +__u32
68256 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68257 + const struct vfsmount * mnt)
68258 +{
68259 + __u32 mode;
68260 +
68261 + if (unlikely(!dentry->d_inode))
68262 + return GR_FIND;
68263 +
68264 + mode =
68265 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
68266 +
68267 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
68268 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
68269 + return mode;
68270 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
68271 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
68272 + return 0;
68273 + } else if (unlikely(!(mode & GR_FIND)))
68274 + return 0;
68275 +
68276 + return GR_FIND;
68277 +}
68278 +
68279 +__u32
68280 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68281 + int acc_mode)
68282 +{
68283 + __u32 reqmode = GR_FIND;
68284 + __u32 mode;
68285 +
68286 + if (unlikely(!dentry->d_inode))
68287 + return reqmode;
68288 +
68289 + if (acc_mode & MAY_APPEND)
68290 + reqmode |= GR_APPEND;
68291 + else if (acc_mode & MAY_WRITE)
68292 + reqmode |= GR_WRITE;
68293 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
68294 + reqmode |= GR_READ;
68295 +
68296 + mode =
68297 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
68298 + mnt);
68299 +
68300 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
68301 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
68302 + reqmode & GR_READ ? " reading" : "",
68303 + reqmode & GR_WRITE ? " writing" : reqmode &
68304 + GR_APPEND ? " appending" : "");
68305 + return reqmode;
68306 + } else
68307 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
68308 + {
68309 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
68310 + reqmode & GR_READ ? " reading" : "",
68311 + reqmode & GR_WRITE ? " writing" : reqmode &
68312 + GR_APPEND ? " appending" : "");
68313 + return 0;
68314 + } else if (unlikely((mode & reqmode) != reqmode))
68315 + return 0;
68316 +
68317 + return reqmode;
68318 +}
68319 +
68320 +__u32
68321 +gr_acl_handle_creat(const struct dentry * dentry,
68322 + const struct dentry * p_dentry,
68323 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
68324 + const int imode)
68325 +{
68326 + __u32 reqmode = GR_WRITE | GR_CREATE;
68327 + __u32 mode;
68328 +
68329 + if (acc_mode & MAY_APPEND)
68330 + reqmode |= GR_APPEND;
68331 + // if a directory was required or the directory already exists, then
68332 + // don't count this open as a read
68333 + if ((acc_mode & MAY_READ) &&
68334 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
68335 + reqmode |= GR_READ;
68336 + if ((open_flags & O_CREAT) &&
68337 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
68338 + reqmode |= GR_SETID;
68339 +
68340 + mode =
68341 + gr_check_create(dentry, p_dentry, p_mnt,
68342 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
68343 +
68344 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
68345 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
68346 + reqmode & GR_READ ? " reading" : "",
68347 + reqmode & GR_WRITE ? " writing" : reqmode &
68348 + GR_APPEND ? " appending" : "");
68349 + return reqmode;
68350 + } else
68351 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
68352 + {
68353 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
68354 + reqmode & GR_READ ? " reading" : "",
68355 + reqmode & GR_WRITE ? " writing" : reqmode &
68356 + GR_APPEND ? " appending" : "");
68357 + return 0;
68358 + } else if (unlikely((mode & reqmode) != reqmode))
68359 + return 0;
68360 +
68361 + return reqmode;
68362 +}
68363 +
68364 +__u32
68365 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
68366 + const int fmode)
68367 +{
68368 + __u32 mode, reqmode = GR_FIND;
68369 +
68370 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
68371 + reqmode |= GR_EXEC;
68372 + if (fmode & S_IWOTH)
68373 + reqmode |= GR_WRITE;
68374 + if (fmode & S_IROTH)
68375 + reqmode |= GR_READ;
68376 +
68377 + mode =
68378 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
68379 + mnt);
68380 +
68381 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
68382 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
68383 + reqmode & GR_READ ? " reading" : "",
68384 + reqmode & GR_WRITE ? " writing" : "",
68385 + reqmode & GR_EXEC ? " executing" : "");
68386 + return reqmode;
68387 + } else
68388 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
68389 + {
68390 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
68391 + reqmode & GR_READ ? " reading" : "",
68392 + reqmode & GR_WRITE ? " writing" : "",
68393 + reqmode & GR_EXEC ? " executing" : "");
68394 + return 0;
68395 + } else if (unlikely((mode & reqmode) != reqmode))
68396 + return 0;
68397 +
68398 + return reqmode;
68399 +}
68400 +
68401 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
68402 +{
68403 + __u32 mode;
68404 +
68405 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
68406 +
68407 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
68408 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
68409 + return mode;
68410 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
68411 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
68412 + return 0;
68413 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
68414 + return 0;
68415 +
68416 + return (reqmode);
68417 +}
68418 +
68419 +__u32
68420 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68421 +{
68422 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
68423 +}
68424 +
68425 +__u32
68426 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
68427 +{
68428 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
68429 +}
68430 +
68431 +__u32
68432 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
68433 +{
68434 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
68435 +}
68436 +
68437 +__u32
68438 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
68439 +{
68440 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
68441 +}
68442 +
68443 +__u32
68444 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
68445 + umode_t *modeptr)
68446 +{
68447 + umode_t mode;
68448 +
68449 + *modeptr &= ~gr_acl_umask();
68450 + mode = *modeptr;
68451 +
68452 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
68453 + return 1;
68454 +
68455 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
68456 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
68457 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
68458 + GR_CHMOD_ACL_MSG);
68459 + } else {
68460 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
68461 + }
68462 +}
68463 +
68464 +__u32
68465 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
68466 +{
68467 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
68468 +}
68469 +
68470 +__u32
68471 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
68472 +{
68473 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
68474 +}
68475 +
68476 +__u32
68477 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
68478 +{
68479 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
68480 +}
68481 +
68482 +__u32
68483 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
68484 +{
68485 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
68486 + GR_UNIXCONNECT_ACL_MSG);
68487 +}
68488 +
68489 +/* hardlinks require at minimum create and link permission,
68490 + any additional privilege required is based on the
68491 + privilege of the file being linked to
68492 +*/
68493 +__u32
68494 +gr_acl_handle_link(const struct dentry * new_dentry,
68495 + const struct dentry * parent_dentry,
68496 + const struct vfsmount * parent_mnt,
68497 + const struct dentry * old_dentry,
68498 + const struct vfsmount * old_mnt, const struct filename *to)
68499 +{
68500 + __u32 mode;
68501 + __u32 needmode = GR_CREATE | GR_LINK;
68502 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
68503 +
68504 + mode =
68505 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
68506 + old_mnt);
68507 +
68508 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
68509 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
68510 + return mode;
68511 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
68512 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
68513 + return 0;
68514 + } else if (unlikely((mode & needmode) != needmode))
68515 + return 0;
68516 +
68517 + return 1;
68518 +}
68519 +
68520 +__u32
68521 +gr_acl_handle_symlink(const struct dentry * new_dentry,
68522 + const struct dentry * parent_dentry,
68523 + const struct vfsmount * parent_mnt, const struct filename *from)
68524 +{
68525 + __u32 needmode = GR_WRITE | GR_CREATE;
68526 + __u32 mode;
68527 +
68528 + mode =
68529 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
68530 + GR_CREATE | GR_AUDIT_CREATE |
68531 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
68532 +
68533 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
68534 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
68535 + return mode;
68536 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
68537 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
68538 + return 0;
68539 + } else if (unlikely((mode & needmode) != needmode))
68540 + return 0;
68541 +
68542 + return (GR_WRITE | GR_CREATE);
68543 +}
68544 +
68545 +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)
68546 +{
68547 + __u32 mode;
68548 +
68549 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
68550 +
68551 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
68552 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
68553 + return mode;
68554 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
68555 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
68556 + return 0;
68557 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
68558 + return 0;
68559 +
68560 + return (reqmode);
68561 +}
68562 +
68563 +__u32
68564 +gr_acl_handle_mknod(const struct dentry * new_dentry,
68565 + const struct dentry * parent_dentry,
68566 + const struct vfsmount * parent_mnt,
68567 + const int mode)
68568 +{
68569 + __u32 reqmode = GR_WRITE | GR_CREATE;
68570 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
68571 + reqmode |= GR_SETID;
68572 +
68573 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
68574 + reqmode, GR_MKNOD_ACL_MSG);
68575 +}
68576 +
68577 +__u32
68578 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
68579 + const struct dentry *parent_dentry,
68580 + const struct vfsmount *parent_mnt)
68581 +{
68582 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
68583 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
68584 +}
68585 +
68586 +#define RENAME_CHECK_SUCCESS(old, new) \
68587 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
68588 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
68589 +
68590 +int
68591 +gr_acl_handle_rename(struct dentry *new_dentry,
68592 + struct dentry *parent_dentry,
68593 + const struct vfsmount *parent_mnt,
68594 + struct dentry *old_dentry,
68595 + struct inode *old_parent_inode,
68596 + struct vfsmount *old_mnt, const struct filename *newname)
68597 +{
68598 + __u32 comp1, comp2;
68599 + int error = 0;
68600 +
68601 + if (unlikely(!gr_acl_is_enabled()))
68602 + return 0;
68603 +
68604 + if (!new_dentry->d_inode) {
68605 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
68606 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
68607 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
68608 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
68609 + GR_DELETE | GR_AUDIT_DELETE |
68610 + GR_AUDIT_READ | GR_AUDIT_WRITE |
68611 + GR_SUPPRESS, old_mnt);
68612 + } else {
68613 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
68614 + GR_CREATE | GR_DELETE |
68615 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
68616 + GR_AUDIT_READ | GR_AUDIT_WRITE |
68617 + GR_SUPPRESS, parent_mnt);
68618 + comp2 =
68619 + gr_search_file(old_dentry,
68620 + GR_READ | GR_WRITE | GR_AUDIT_READ |
68621 + GR_DELETE | GR_AUDIT_DELETE |
68622 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
68623 + }
68624 +
68625 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
68626 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
68627 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
68628 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
68629 + && !(comp2 & GR_SUPPRESS)) {
68630 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
68631 + error = -EACCES;
68632 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
68633 + error = -EACCES;
68634 +
68635 + return error;
68636 +}
68637 +
68638 +void
68639 +gr_acl_handle_exit(void)
68640 +{
68641 + u16 id;
68642 + char *rolename;
68643 +
68644 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
68645 + !(current->role->roletype & GR_ROLE_PERSIST))) {
68646 + id = current->acl_role_id;
68647 + rolename = current->role->rolename;
68648 + gr_set_acls(1);
68649 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
68650 + }
68651 +
68652 + gr_put_exec_file(current);
68653 + return;
68654 +}
68655 +
68656 +int
68657 +gr_acl_handle_procpidmem(const struct task_struct *task)
68658 +{
68659 + if (unlikely(!gr_acl_is_enabled()))
68660 + return 0;
68661 +
68662 + if (task != current && task->acl->mode & GR_PROTPROCFD)
68663 + return -EACCES;
68664 +
68665 + return 0;
68666 +}
68667 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
68668 new file mode 100644
68669 index 0000000..8132048
68670 --- /dev/null
68671 +++ b/grsecurity/gracl_ip.c
68672 @@ -0,0 +1,387 @@
68673 +#include <linux/kernel.h>
68674 +#include <asm/uaccess.h>
68675 +#include <asm/errno.h>
68676 +#include <net/sock.h>
68677 +#include <linux/file.h>
68678 +#include <linux/fs.h>
68679 +#include <linux/net.h>
68680 +#include <linux/in.h>
68681 +#include <linux/skbuff.h>
68682 +#include <linux/ip.h>
68683 +#include <linux/udp.h>
68684 +#include <linux/types.h>
68685 +#include <linux/sched.h>
68686 +#include <linux/netdevice.h>
68687 +#include <linux/inetdevice.h>
68688 +#include <linux/gracl.h>
68689 +#include <linux/grsecurity.h>
68690 +#include <linux/grinternal.h>
68691 +
68692 +#define GR_BIND 0x01
68693 +#define GR_CONNECT 0x02
68694 +#define GR_INVERT 0x04
68695 +#define GR_BINDOVERRIDE 0x08
68696 +#define GR_CONNECTOVERRIDE 0x10
68697 +#define GR_SOCK_FAMILY 0x20
68698 +
68699 +static const char * gr_protocols[IPPROTO_MAX] = {
68700 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
68701 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
68702 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
68703 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
68704 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
68705 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
68706 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
68707 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
68708 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
68709 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
68710 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
68711 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
68712 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
68713 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
68714 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
68715 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
68716 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
68717 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
68718 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
68719 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
68720 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
68721 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
68722 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
68723 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
68724 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
68725 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
68726 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
68727 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
68728 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
68729 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
68730 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
68731 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
68732 + };
68733 +
68734 +static const char * gr_socktypes[SOCK_MAX] = {
68735 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
68736 + "unknown:7", "unknown:8", "unknown:9", "packet"
68737 + };
68738 +
68739 +static const char * gr_sockfamilies[AF_MAX+1] = {
68740 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
68741 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
68742 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
68743 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
68744 + };
68745 +
68746 +const char *
68747 +gr_proto_to_name(unsigned char proto)
68748 +{
68749 + return gr_protocols[proto];
68750 +}
68751 +
68752 +const char *
68753 +gr_socktype_to_name(unsigned char type)
68754 +{
68755 + return gr_socktypes[type];
68756 +}
68757 +
68758 +const char *
68759 +gr_sockfamily_to_name(unsigned char family)
68760 +{
68761 + return gr_sockfamilies[family];
68762 +}
68763 +
68764 +int
68765 +gr_search_socket(const int domain, const int type, const int protocol)
68766 +{
68767 + struct acl_subject_label *curr;
68768 + const struct cred *cred = current_cred();
68769 +
68770 + if (unlikely(!gr_acl_is_enabled()))
68771 + goto exit;
68772 +
68773 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
68774 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
68775 + goto exit; // let the kernel handle it
68776 +
68777 + curr = current->acl;
68778 +
68779 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
68780 + /* the family is allowed, if this is PF_INET allow it only if
68781 + the extra sock type/protocol checks pass */
68782 + if (domain == PF_INET)
68783 + goto inet_check;
68784 + goto exit;
68785 + } else {
68786 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
68787 + __u32 fakeip = 0;
68788 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68789 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68790 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68791 + gr_to_filename(current->exec_file->f_path.dentry,
68792 + current->exec_file->f_path.mnt) :
68793 + curr->filename, curr->filename,
68794 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
68795 + &current->signal->saved_ip);
68796 + goto exit;
68797 + }
68798 + goto exit_fail;
68799 + }
68800 +
68801 +inet_check:
68802 + /* the rest of this checking is for IPv4 only */
68803 + if (!curr->ips)
68804 + goto exit;
68805 +
68806 + if ((curr->ip_type & (1U << type)) &&
68807 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
68808 + goto exit;
68809 +
68810 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
68811 + /* we don't place acls on raw sockets , and sometimes
68812 + dgram/ip sockets are opened for ioctl and not
68813 + bind/connect, so we'll fake a bind learn log */
68814 + if (type == SOCK_RAW || type == SOCK_PACKET) {
68815 + __u32 fakeip = 0;
68816 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68817 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68818 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68819 + gr_to_filename(current->exec_file->f_path.dentry,
68820 + current->exec_file->f_path.mnt) :
68821 + curr->filename, curr->filename,
68822 + &fakeip, 0, type,
68823 + protocol, GR_CONNECT, &current->signal->saved_ip);
68824 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
68825 + __u32 fakeip = 0;
68826 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68827 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68828 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68829 + gr_to_filename(current->exec_file->f_path.dentry,
68830 + current->exec_file->f_path.mnt) :
68831 + curr->filename, curr->filename,
68832 + &fakeip, 0, type,
68833 + protocol, GR_BIND, &current->signal->saved_ip);
68834 + }
68835 + /* we'll log when they use connect or bind */
68836 + goto exit;
68837 + }
68838 +
68839 +exit_fail:
68840 + if (domain == PF_INET)
68841 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
68842 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
68843 + else
68844 +#ifndef CONFIG_IPV6
68845 + if (domain != PF_INET6)
68846 +#endif
68847 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
68848 + gr_socktype_to_name(type), protocol);
68849 +
68850 + return 0;
68851 +exit:
68852 + return 1;
68853 +}
68854 +
68855 +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)
68856 +{
68857 + if ((ip->mode & mode) &&
68858 + (ip_port >= ip->low) &&
68859 + (ip_port <= ip->high) &&
68860 + ((ntohl(ip_addr) & our_netmask) ==
68861 + (ntohl(our_addr) & our_netmask))
68862 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
68863 + && (ip->type & (1U << type))) {
68864 + if (ip->mode & GR_INVERT)
68865 + return 2; // specifically denied
68866 + else
68867 + return 1; // allowed
68868 + }
68869 +
68870 + return 0; // not specifically allowed, may continue parsing
68871 +}
68872 +
68873 +static int
68874 +gr_search_connectbind(const int full_mode, struct sock *sk,
68875 + struct sockaddr_in *addr, const int type)
68876 +{
68877 + char iface[IFNAMSIZ] = {0};
68878 + struct acl_subject_label *curr;
68879 + struct acl_ip_label *ip;
68880 + struct inet_sock *isk;
68881 + struct net_device *dev;
68882 + struct in_device *idev;
68883 + unsigned long i;
68884 + int ret;
68885 + int mode = full_mode & (GR_BIND | GR_CONNECT);
68886 + __u32 ip_addr = 0;
68887 + __u32 our_addr;
68888 + __u32 our_netmask;
68889 + char *p;
68890 + __u16 ip_port = 0;
68891 + const struct cred *cred = current_cred();
68892 +
68893 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
68894 + return 0;
68895 +
68896 + curr = current->acl;
68897 + isk = inet_sk(sk);
68898 +
68899 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
68900 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
68901 + addr->sin_addr.s_addr = curr->inaddr_any_override;
68902 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
68903 + struct sockaddr_in saddr;
68904 + int err;
68905 +
68906 + saddr.sin_family = AF_INET;
68907 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
68908 + saddr.sin_port = isk->inet_sport;
68909 +
68910 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
68911 + if (err)
68912 + return err;
68913 +
68914 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
68915 + if (err)
68916 + return err;
68917 + }
68918 +
68919 + if (!curr->ips)
68920 + return 0;
68921 +
68922 + ip_addr = addr->sin_addr.s_addr;
68923 + ip_port = ntohs(addr->sin_port);
68924 +
68925 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
68926 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68927 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68928 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68929 + gr_to_filename(current->exec_file->f_path.dentry,
68930 + current->exec_file->f_path.mnt) :
68931 + curr->filename, curr->filename,
68932 + &ip_addr, ip_port, type,
68933 + sk->sk_protocol, mode, &current->signal->saved_ip);
68934 + return 0;
68935 + }
68936 +
68937 + for (i = 0; i < curr->ip_num; i++) {
68938 + ip = *(curr->ips + i);
68939 + if (ip->iface != NULL) {
68940 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
68941 + p = strchr(iface, ':');
68942 + if (p != NULL)
68943 + *p = '\0';
68944 + dev = dev_get_by_name(sock_net(sk), iface);
68945 + if (dev == NULL)
68946 + continue;
68947 + idev = in_dev_get(dev);
68948 + if (idev == NULL) {
68949 + dev_put(dev);
68950 + continue;
68951 + }
68952 + rcu_read_lock();
68953 + for_ifa(idev) {
68954 + if (!strcmp(ip->iface, ifa->ifa_label)) {
68955 + our_addr = ifa->ifa_address;
68956 + our_netmask = 0xffffffff;
68957 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
68958 + if (ret == 1) {
68959 + rcu_read_unlock();
68960 + in_dev_put(idev);
68961 + dev_put(dev);
68962 + return 0;
68963 + } else if (ret == 2) {
68964 + rcu_read_unlock();
68965 + in_dev_put(idev);
68966 + dev_put(dev);
68967 + goto denied;
68968 + }
68969 + }
68970 + } endfor_ifa(idev);
68971 + rcu_read_unlock();
68972 + in_dev_put(idev);
68973 + dev_put(dev);
68974 + } else {
68975 + our_addr = ip->addr;
68976 + our_netmask = ip->netmask;
68977 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
68978 + if (ret == 1)
68979 + return 0;
68980 + else if (ret == 2)
68981 + goto denied;
68982 + }
68983 + }
68984 +
68985 +denied:
68986 + if (mode == GR_BIND)
68987 + 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));
68988 + else if (mode == GR_CONNECT)
68989 + 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));
68990 +
68991 + return -EACCES;
68992 +}
68993 +
68994 +int
68995 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
68996 +{
68997 + /* always allow disconnection of dgram sockets with connect */
68998 + if (addr->sin_family == AF_UNSPEC)
68999 + return 0;
69000 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
69001 +}
69002 +
69003 +int
69004 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
69005 +{
69006 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
69007 +}
69008 +
69009 +int gr_search_listen(struct socket *sock)
69010 +{
69011 + struct sock *sk = sock->sk;
69012 + struct sockaddr_in addr;
69013 +
69014 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
69015 + addr.sin_port = inet_sk(sk)->inet_sport;
69016 +
69017 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
69018 +}
69019 +
69020 +int gr_search_accept(struct socket *sock)
69021 +{
69022 + struct sock *sk = sock->sk;
69023 + struct sockaddr_in addr;
69024 +
69025 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
69026 + addr.sin_port = inet_sk(sk)->inet_sport;
69027 +
69028 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
69029 +}
69030 +
69031 +int
69032 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
69033 +{
69034 + if (addr)
69035 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
69036 + else {
69037 + struct sockaddr_in sin;
69038 + const struct inet_sock *inet = inet_sk(sk);
69039 +
69040 + sin.sin_addr.s_addr = inet->inet_daddr;
69041 + sin.sin_port = inet->inet_dport;
69042 +
69043 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
69044 + }
69045 +}
69046 +
69047 +int
69048 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
69049 +{
69050 + struct sockaddr_in sin;
69051 +
69052 + if (unlikely(skb->len < sizeof (struct udphdr)))
69053 + return 0; // skip this packet
69054 +
69055 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
69056 + sin.sin_port = udp_hdr(skb)->source;
69057 +
69058 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
69059 +}
69060 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
69061 new file mode 100644
69062 index 0000000..25f54ef
69063 --- /dev/null
69064 +++ b/grsecurity/gracl_learn.c
69065 @@ -0,0 +1,207 @@
69066 +#include <linux/kernel.h>
69067 +#include <linux/mm.h>
69068 +#include <linux/sched.h>
69069 +#include <linux/poll.h>
69070 +#include <linux/string.h>
69071 +#include <linux/file.h>
69072 +#include <linux/types.h>
69073 +#include <linux/vmalloc.h>
69074 +#include <linux/grinternal.h>
69075 +
69076 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
69077 + size_t count, loff_t *ppos);
69078 +extern int gr_acl_is_enabled(void);
69079 +
69080 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
69081 +static int gr_learn_attached;
69082 +
69083 +/* use a 512k buffer */
69084 +#define LEARN_BUFFER_SIZE (512 * 1024)
69085 +
69086 +static DEFINE_SPINLOCK(gr_learn_lock);
69087 +static DEFINE_MUTEX(gr_learn_user_mutex);
69088 +
69089 +/* we need to maintain two buffers, so that the kernel context of grlearn
69090 + uses a semaphore around the userspace copying, and the other kernel contexts
69091 + use a spinlock when copying into the buffer, since they cannot sleep
69092 +*/
69093 +static char *learn_buffer;
69094 +static char *learn_buffer_user;
69095 +static int learn_buffer_len;
69096 +static int learn_buffer_user_len;
69097 +
69098 +static ssize_t
69099 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
69100 +{
69101 + DECLARE_WAITQUEUE(wait, current);
69102 + ssize_t retval = 0;
69103 +
69104 + add_wait_queue(&learn_wait, &wait);
69105 + set_current_state(TASK_INTERRUPTIBLE);
69106 + do {
69107 + mutex_lock(&gr_learn_user_mutex);
69108 + spin_lock(&gr_learn_lock);
69109 + if (learn_buffer_len)
69110 + break;
69111 + spin_unlock(&gr_learn_lock);
69112 + mutex_unlock(&gr_learn_user_mutex);
69113 + if (file->f_flags & O_NONBLOCK) {
69114 + retval = -EAGAIN;
69115 + goto out;
69116 + }
69117 + if (signal_pending(current)) {
69118 + retval = -ERESTARTSYS;
69119 + goto out;
69120 + }
69121 +
69122 + schedule();
69123 + } while (1);
69124 +
69125 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
69126 + learn_buffer_user_len = learn_buffer_len;
69127 + retval = learn_buffer_len;
69128 + learn_buffer_len = 0;
69129 +
69130 + spin_unlock(&gr_learn_lock);
69131 +
69132 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
69133 + retval = -EFAULT;
69134 +
69135 + mutex_unlock(&gr_learn_user_mutex);
69136 +out:
69137 + set_current_state(TASK_RUNNING);
69138 + remove_wait_queue(&learn_wait, &wait);
69139 + return retval;
69140 +}
69141 +
69142 +static unsigned int
69143 +poll_learn(struct file * file, poll_table * wait)
69144 +{
69145 + poll_wait(file, &learn_wait, wait);
69146 +
69147 + if (learn_buffer_len)
69148 + return (POLLIN | POLLRDNORM);
69149 +
69150 + return 0;
69151 +}
69152 +
69153 +void
69154 +gr_clear_learn_entries(void)
69155 +{
69156 + char *tmp;
69157 +
69158 + mutex_lock(&gr_learn_user_mutex);
69159 + spin_lock(&gr_learn_lock);
69160 + tmp = learn_buffer;
69161 + learn_buffer = NULL;
69162 + spin_unlock(&gr_learn_lock);
69163 + if (tmp)
69164 + vfree(tmp);
69165 + if (learn_buffer_user != NULL) {
69166 + vfree(learn_buffer_user);
69167 + learn_buffer_user = NULL;
69168 + }
69169 + learn_buffer_len = 0;
69170 + mutex_unlock(&gr_learn_user_mutex);
69171 +
69172 + return;
69173 +}
69174 +
69175 +void
69176 +gr_add_learn_entry(const char *fmt, ...)
69177 +{
69178 + va_list args;
69179 + unsigned int len;
69180 +
69181 + if (!gr_learn_attached)
69182 + return;
69183 +
69184 + spin_lock(&gr_learn_lock);
69185 +
69186 + /* leave a gap at the end so we know when it's "full" but don't have to
69187 + compute the exact length of the string we're trying to append
69188 + */
69189 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
69190 + spin_unlock(&gr_learn_lock);
69191 + wake_up_interruptible(&learn_wait);
69192 + return;
69193 + }
69194 + if (learn_buffer == NULL) {
69195 + spin_unlock(&gr_learn_lock);
69196 + return;
69197 + }
69198 +
69199 + va_start(args, fmt);
69200 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
69201 + va_end(args);
69202 +
69203 + learn_buffer_len += len + 1;
69204 +
69205 + spin_unlock(&gr_learn_lock);
69206 + wake_up_interruptible(&learn_wait);
69207 +
69208 + return;
69209 +}
69210 +
69211 +static int
69212 +open_learn(struct inode *inode, struct file *file)
69213 +{
69214 + if (file->f_mode & FMODE_READ && gr_learn_attached)
69215 + return -EBUSY;
69216 + if (file->f_mode & FMODE_READ) {
69217 + int retval = 0;
69218 + mutex_lock(&gr_learn_user_mutex);
69219 + if (learn_buffer == NULL)
69220 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
69221 + if (learn_buffer_user == NULL)
69222 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
69223 + if (learn_buffer == NULL) {
69224 + retval = -ENOMEM;
69225 + goto out_error;
69226 + }
69227 + if (learn_buffer_user == NULL) {
69228 + retval = -ENOMEM;
69229 + goto out_error;
69230 + }
69231 + learn_buffer_len = 0;
69232 + learn_buffer_user_len = 0;
69233 + gr_learn_attached = 1;
69234 +out_error:
69235 + mutex_unlock(&gr_learn_user_mutex);
69236 + return retval;
69237 + }
69238 + return 0;
69239 +}
69240 +
69241 +static int
69242 +close_learn(struct inode *inode, struct file *file)
69243 +{
69244 + if (file->f_mode & FMODE_READ) {
69245 + char *tmp = NULL;
69246 + mutex_lock(&gr_learn_user_mutex);
69247 + spin_lock(&gr_learn_lock);
69248 + tmp = learn_buffer;
69249 + learn_buffer = NULL;
69250 + spin_unlock(&gr_learn_lock);
69251 + if (tmp)
69252 + vfree(tmp);
69253 + if (learn_buffer_user != NULL) {
69254 + vfree(learn_buffer_user);
69255 + learn_buffer_user = NULL;
69256 + }
69257 + learn_buffer_len = 0;
69258 + learn_buffer_user_len = 0;
69259 + gr_learn_attached = 0;
69260 + mutex_unlock(&gr_learn_user_mutex);
69261 + }
69262 +
69263 + return 0;
69264 +}
69265 +
69266 +const struct file_operations grsec_fops = {
69267 + .read = read_learn,
69268 + .write = write_grsec_handler,
69269 + .open = open_learn,
69270 + .release = close_learn,
69271 + .poll = poll_learn,
69272 +};
69273 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
69274 new file mode 100644
69275 index 0000000..39645c9
69276 --- /dev/null
69277 +++ b/grsecurity/gracl_res.c
69278 @@ -0,0 +1,68 @@
69279 +#include <linux/kernel.h>
69280 +#include <linux/sched.h>
69281 +#include <linux/gracl.h>
69282 +#include <linux/grinternal.h>
69283 +
69284 +static const char *restab_log[] = {
69285 + [RLIMIT_CPU] = "RLIMIT_CPU",
69286 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
69287 + [RLIMIT_DATA] = "RLIMIT_DATA",
69288 + [RLIMIT_STACK] = "RLIMIT_STACK",
69289 + [RLIMIT_CORE] = "RLIMIT_CORE",
69290 + [RLIMIT_RSS] = "RLIMIT_RSS",
69291 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
69292 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
69293 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
69294 + [RLIMIT_AS] = "RLIMIT_AS",
69295 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
69296 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
69297 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
69298 + [RLIMIT_NICE] = "RLIMIT_NICE",
69299 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
69300 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
69301 + [GR_CRASH_RES] = "RLIMIT_CRASH"
69302 +};
69303 +
69304 +void
69305 +gr_log_resource(const struct task_struct *task,
69306 + const int res, const unsigned long wanted, const int gt)
69307 +{
69308 + const struct cred *cred;
69309 + unsigned long rlim;
69310 +
69311 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
69312 + return;
69313 +
69314 + // not yet supported resource
69315 + if (unlikely(!restab_log[res]))
69316 + return;
69317 +
69318 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
69319 + rlim = task_rlimit_max(task, res);
69320 + else
69321 + rlim = task_rlimit(task, res);
69322 +
69323 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
69324 + return;
69325 +
69326 + rcu_read_lock();
69327 + cred = __task_cred(task);
69328 +
69329 + if (res == RLIMIT_NPROC &&
69330 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
69331 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
69332 + goto out_rcu_unlock;
69333 + else if (res == RLIMIT_MEMLOCK &&
69334 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
69335 + goto out_rcu_unlock;
69336 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
69337 + goto out_rcu_unlock;
69338 + rcu_read_unlock();
69339 +
69340 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
69341 +
69342 + return;
69343 +out_rcu_unlock:
69344 + rcu_read_unlock();
69345 + return;
69346 +}
69347 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
69348 new file mode 100644
69349 index 0000000..3c38bfe
69350 --- /dev/null
69351 +++ b/grsecurity/gracl_segv.c
69352 @@ -0,0 +1,305 @@
69353 +#include <linux/kernel.h>
69354 +#include <linux/mm.h>
69355 +#include <asm/uaccess.h>
69356 +#include <asm/errno.h>
69357 +#include <asm/mman.h>
69358 +#include <net/sock.h>
69359 +#include <linux/file.h>
69360 +#include <linux/fs.h>
69361 +#include <linux/net.h>
69362 +#include <linux/in.h>
69363 +#include <linux/slab.h>
69364 +#include <linux/types.h>
69365 +#include <linux/sched.h>
69366 +#include <linux/timer.h>
69367 +#include <linux/gracl.h>
69368 +#include <linux/grsecurity.h>
69369 +#include <linux/grinternal.h>
69370 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69371 +#include <linux/magic.h>
69372 +#include <linux/pagemap.h>
69373 +#include "../fs/btrfs/async-thread.h"
69374 +#include "../fs/btrfs/ctree.h"
69375 +#include "../fs/btrfs/btrfs_inode.h"
69376 +#endif
69377 +
69378 +static struct crash_uid *uid_set;
69379 +static unsigned short uid_used;
69380 +static DEFINE_SPINLOCK(gr_uid_lock);
69381 +extern rwlock_t gr_inode_lock;
69382 +extern struct acl_subject_label *
69383 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
69384 + struct acl_role_label *role);
69385 +
69386 +static inline dev_t __get_dev(const struct dentry *dentry)
69387 +{
69388 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69389 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
69390 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
69391 + else
69392 +#endif
69393 + return dentry->d_sb->s_dev;
69394 +}
69395 +
69396 +int
69397 +gr_init_uidset(void)
69398 +{
69399 + uid_set =
69400 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
69401 + uid_used = 0;
69402 +
69403 + return uid_set ? 1 : 0;
69404 +}
69405 +
69406 +void
69407 +gr_free_uidset(void)
69408 +{
69409 + if (uid_set)
69410 + kfree(uid_set);
69411 +
69412 + return;
69413 +}
69414 +
69415 +int
69416 +gr_find_uid(const uid_t uid)
69417 +{
69418 + struct crash_uid *tmp = uid_set;
69419 + uid_t buid;
69420 + int low = 0, high = uid_used - 1, mid;
69421 +
69422 + while (high >= low) {
69423 + mid = (low + high) >> 1;
69424 + buid = tmp[mid].uid;
69425 + if (buid == uid)
69426 + return mid;
69427 + if (buid > uid)
69428 + high = mid - 1;
69429 + if (buid < uid)
69430 + low = mid + 1;
69431 + }
69432 +
69433 + return -1;
69434 +}
69435 +
69436 +static __inline__ void
69437 +gr_insertsort(void)
69438 +{
69439 + unsigned short i, j;
69440 + struct crash_uid index;
69441 +
69442 + for (i = 1; i < uid_used; i++) {
69443 + index = uid_set[i];
69444 + j = i;
69445 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
69446 + uid_set[j] = uid_set[j - 1];
69447 + j--;
69448 + }
69449 + uid_set[j] = index;
69450 + }
69451 +
69452 + return;
69453 +}
69454 +
69455 +static __inline__ void
69456 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
69457 +{
69458 + int loc;
69459 + uid_t uid = GR_GLOBAL_UID(kuid);
69460 +
69461 + if (uid_used == GR_UIDTABLE_MAX)
69462 + return;
69463 +
69464 + loc = gr_find_uid(uid);
69465 +
69466 + if (loc >= 0) {
69467 + uid_set[loc].expires = expires;
69468 + return;
69469 + }
69470 +
69471 + uid_set[uid_used].uid = uid;
69472 + uid_set[uid_used].expires = expires;
69473 + uid_used++;
69474 +
69475 + gr_insertsort();
69476 +
69477 + return;
69478 +}
69479 +
69480 +void
69481 +gr_remove_uid(const unsigned short loc)
69482 +{
69483 + unsigned short i;
69484 +
69485 + for (i = loc + 1; i < uid_used; i++)
69486 + uid_set[i - 1] = uid_set[i];
69487 +
69488 + uid_used--;
69489 +
69490 + return;
69491 +}
69492 +
69493 +int
69494 +gr_check_crash_uid(const kuid_t kuid)
69495 +{
69496 + int loc;
69497 + int ret = 0;
69498 + uid_t uid;
69499 +
69500 + if (unlikely(!gr_acl_is_enabled()))
69501 + return 0;
69502 +
69503 + uid = GR_GLOBAL_UID(kuid);
69504 +
69505 + spin_lock(&gr_uid_lock);
69506 + loc = gr_find_uid(uid);
69507 +
69508 + if (loc < 0)
69509 + goto out_unlock;
69510 +
69511 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69512 + gr_remove_uid(loc);
69513 + else
69514 + ret = 1;
69515 +
69516 +out_unlock:
69517 + spin_unlock(&gr_uid_lock);
69518 + return ret;
69519 +}
69520 +
69521 +static __inline__ int
69522 +proc_is_setxid(const struct cred *cred)
69523 +{
69524 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69525 + !uid_eq(cred->uid, cred->fsuid))
69526 + return 1;
69527 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69528 + !gid_eq(cred->gid, cred->fsgid))
69529 + return 1;
69530 +
69531 + return 0;
69532 +}
69533 +
69534 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69535 +
69536 +void
69537 +gr_handle_crash(struct task_struct *task, const int sig)
69538 +{
69539 + struct acl_subject_label *curr;
69540 + struct task_struct *tsk, *tsk2;
69541 + const struct cred *cred;
69542 + const struct cred *cred2;
69543 +
69544 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69545 + return;
69546 +
69547 + if (unlikely(!gr_acl_is_enabled()))
69548 + return;
69549 +
69550 + curr = task->acl;
69551 +
69552 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69553 + return;
69554 +
69555 + if (time_before_eq(curr->expires, get_seconds())) {
69556 + curr->expires = 0;
69557 + curr->crashes = 0;
69558 + }
69559 +
69560 + curr->crashes++;
69561 +
69562 + if (!curr->expires)
69563 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69564 +
69565 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69566 + time_after(curr->expires, get_seconds())) {
69567 + rcu_read_lock();
69568 + cred = __task_cred(task);
69569 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69570 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69571 + spin_lock(&gr_uid_lock);
69572 + gr_insert_uid(cred->uid, curr->expires);
69573 + spin_unlock(&gr_uid_lock);
69574 + curr->expires = 0;
69575 + curr->crashes = 0;
69576 + read_lock(&tasklist_lock);
69577 + do_each_thread(tsk2, tsk) {
69578 + cred2 = __task_cred(tsk);
69579 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69580 + gr_fake_force_sig(SIGKILL, tsk);
69581 + } while_each_thread(tsk2, tsk);
69582 + read_unlock(&tasklist_lock);
69583 + } else {
69584 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69585 + read_lock(&tasklist_lock);
69586 + read_lock(&grsec_exec_file_lock);
69587 + do_each_thread(tsk2, tsk) {
69588 + if (likely(tsk != task)) {
69589 + // if this thread has the same subject as the one that triggered
69590 + // RES_CRASH and it's the same binary, kill it
69591 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69592 + gr_fake_force_sig(SIGKILL, tsk);
69593 + }
69594 + } while_each_thread(tsk2, tsk);
69595 + read_unlock(&grsec_exec_file_lock);
69596 + read_unlock(&tasklist_lock);
69597 + }
69598 + rcu_read_unlock();
69599 + }
69600 +
69601 + return;
69602 +}
69603 +
69604 +int
69605 +gr_check_crash_exec(const struct file *filp)
69606 +{
69607 + struct acl_subject_label *curr;
69608 +
69609 + if (unlikely(!gr_acl_is_enabled()))
69610 + return 0;
69611 +
69612 + read_lock(&gr_inode_lock);
69613 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69614 + __get_dev(filp->f_path.dentry),
69615 + current->role);
69616 + read_unlock(&gr_inode_lock);
69617 +
69618 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69619 + (!curr->crashes && !curr->expires))
69620 + return 0;
69621 +
69622 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69623 + time_after(curr->expires, get_seconds()))
69624 + return 1;
69625 + else if (time_before_eq(curr->expires, get_seconds())) {
69626 + curr->crashes = 0;
69627 + curr->expires = 0;
69628 + }
69629 +
69630 + return 0;
69631 +}
69632 +
69633 +void
69634 +gr_handle_alertkill(struct task_struct *task)
69635 +{
69636 + struct acl_subject_label *curracl;
69637 + __u32 curr_ip;
69638 + struct task_struct *p, *p2;
69639 +
69640 + if (unlikely(!gr_acl_is_enabled()))
69641 + return;
69642 +
69643 + curracl = task->acl;
69644 + curr_ip = task->signal->curr_ip;
69645 +
69646 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69647 + read_lock(&tasklist_lock);
69648 + do_each_thread(p2, p) {
69649 + if (p->signal->curr_ip == curr_ip)
69650 + gr_fake_force_sig(SIGKILL, p);
69651 + } while_each_thread(p2, p);
69652 + read_unlock(&tasklist_lock);
69653 + } else if (curracl->mode & GR_KILLPROC)
69654 + gr_fake_force_sig(SIGKILL, task);
69655 +
69656 + return;
69657 +}
69658 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69659 new file mode 100644
69660 index 0000000..98011b0
69661 --- /dev/null
69662 +++ b/grsecurity/gracl_shm.c
69663 @@ -0,0 +1,40 @@
69664 +#include <linux/kernel.h>
69665 +#include <linux/mm.h>
69666 +#include <linux/sched.h>
69667 +#include <linux/file.h>
69668 +#include <linux/ipc.h>
69669 +#include <linux/gracl.h>
69670 +#include <linux/grsecurity.h>
69671 +#include <linux/grinternal.h>
69672 +
69673 +int
69674 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69675 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69676 +{
69677 + struct task_struct *task;
69678 +
69679 + if (!gr_acl_is_enabled())
69680 + return 1;
69681 +
69682 + rcu_read_lock();
69683 + read_lock(&tasklist_lock);
69684 +
69685 + task = find_task_by_vpid(shm_cprid);
69686 +
69687 + if (unlikely(!task))
69688 + task = find_task_by_vpid(shm_lapid);
69689 +
69690 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69691 + (task_pid_nr(task) == shm_lapid)) &&
69692 + (task->acl->mode & GR_PROTSHM) &&
69693 + (task->acl != current->acl))) {
69694 + read_unlock(&tasklist_lock);
69695 + rcu_read_unlock();
69696 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69697 + return 0;
69698 + }
69699 + read_unlock(&tasklist_lock);
69700 + rcu_read_unlock();
69701 +
69702 + return 1;
69703 +}
69704 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69705 new file mode 100644
69706 index 0000000..bc0be01
69707 --- /dev/null
69708 +++ b/grsecurity/grsec_chdir.c
69709 @@ -0,0 +1,19 @@
69710 +#include <linux/kernel.h>
69711 +#include <linux/sched.h>
69712 +#include <linux/fs.h>
69713 +#include <linux/file.h>
69714 +#include <linux/grsecurity.h>
69715 +#include <linux/grinternal.h>
69716 +
69717 +void
69718 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69719 +{
69720 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69721 + if ((grsec_enable_chdir && grsec_enable_group &&
69722 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69723 + !grsec_enable_group)) {
69724 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69725 + }
69726 +#endif
69727 + return;
69728 +}
69729 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69730 new file mode 100644
69731 index 0000000..bd6e105
69732 --- /dev/null
69733 +++ b/grsecurity/grsec_chroot.c
69734 @@ -0,0 +1,370 @@
69735 +#include <linux/kernel.h>
69736 +#include <linux/module.h>
69737 +#include <linux/sched.h>
69738 +#include <linux/file.h>
69739 +#include <linux/fs.h>
69740 +#include <linux/mount.h>
69741 +#include <linux/types.h>
69742 +#include "../fs/mount.h"
69743 +#include <linux/grsecurity.h>
69744 +#include <linux/grinternal.h>
69745 +
69746 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69747 +static int gr_init_ran;
69748 +#endif
69749 +
69750 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69751 +{
69752 +#ifdef CONFIG_GRKERNSEC
69753 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69754 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69755 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69756 + && gr_init_ran
69757 +#endif
69758 + )
69759 + task->gr_is_chrooted = 1;
69760 + else {
69761 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69762 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69763 + gr_init_ran = 1;
69764 +#endif
69765 + task->gr_is_chrooted = 0;
69766 + }
69767 +
69768 + task->gr_chroot_dentry = path->dentry;
69769 +#endif
69770 + return;
69771 +}
69772 +
69773 +void gr_clear_chroot_entries(struct task_struct *task)
69774 +{
69775 +#ifdef CONFIG_GRKERNSEC
69776 + task->gr_is_chrooted = 0;
69777 + task->gr_chroot_dentry = NULL;
69778 +#endif
69779 + return;
69780 +}
69781 +
69782 +int
69783 +gr_handle_chroot_unix(const pid_t pid)
69784 +{
69785 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69786 + struct task_struct *p;
69787 +
69788 + if (unlikely(!grsec_enable_chroot_unix))
69789 + return 1;
69790 +
69791 + if (likely(!proc_is_chrooted(current)))
69792 + return 1;
69793 +
69794 + rcu_read_lock();
69795 + read_lock(&tasklist_lock);
69796 + p = find_task_by_vpid_unrestricted(pid);
69797 + if (unlikely(p && !have_same_root(current, p))) {
69798 + read_unlock(&tasklist_lock);
69799 + rcu_read_unlock();
69800 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69801 + return 0;
69802 + }
69803 + read_unlock(&tasklist_lock);
69804 + rcu_read_unlock();
69805 +#endif
69806 + return 1;
69807 +}
69808 +
69809 +int
69810 +gr_handle_chroot_nice(void)
69811 +{
69812 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69813 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69814 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69815 + return -EPERM;
69816 + }
69817 +#endif
69818 + return 0;
69819 +}
69820 +
69821 +int
69822 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
69823 +{
69824 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69825 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
69826 + && proc_is_chrooted(current)) {
69827 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
69828 + return -EACCES;
69829 + }
69830 +#endif
69831 + return 0;
69832 +}
69833 +
69834 +int
69835 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
69836 +{
69837 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69838 + struct task_struct *p;
69839 + int ret = 0;
69840 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
69841 + return ret;
69842 +
69843 + read_lock(&tasklist_lock);
69844 + do_each_pid_task(pid, type, p) {
69845 + if (!have_same_root(current, p)) {
69846 + ret = 1;
69847 + goto out;
69848 + }
69849 + } while_each_pid_task(pid, type, p);
69850 +out:
69851 + read_unlock(&tasklist_lock);
69852 + return ret;
69853 +#endif
69854 + return 0;
69855 +}
69856 +
69857 +int
69858 +gr_pid_is_chrooted(struct task_struct *p)
69859 +{
69860 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69861 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
69862 + return 0;
69863 +
69864 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
69865 + !have_same_root(current, p)) {
69866 + return 1;
69867 + }
69868 +#endif
69869 + return 0;
69870 +}
69871 +
69872 +EXPORT_SYMBOL(gr_pid_is_chrooted);
69873 +
69874 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
69875 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
69876 +{
69877 + struct path path, currentroot;
69878 + int ret = 0;
69879 +
69880 + path.dentry = (struct dentry *)u_dentry;
69881 + path.mnt = (struct vfsmount *)u_mnt;
69882 + get_fs_root(current->fs, &currentroot);
69883 + if (path_is_under(&path, &currentroot))
69884 + ret = 1;
69885 + path_put(&currentroot);
69886 +
69887 + return ret;
69888 +}
69889 +#endif
69890 +
69891 +int
69892 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
69893 +{
69894 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69895 + if (!grsec_enable_chroot_fchdir)
69896 + return 1;
69897 +
69898 + if (!proc_is_chrooted(current))
69899 + return 1;
69900 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
69901 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
69902 + return 0;
69903 + }
69904 +#endif
69905 + return 1;
69906 +}
69907 +
69908 +int
69909 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69910 + const time_t shm_createtime)
69911 +{
69912 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69913 + struct task_struct *p;
69914 + time_t starttime;
69915 +
69916 + if (unlikely(!grsec_enable_chroot_shmat))
69917 + return 1;
69918 +
69919 + if (likely(!proc_is_chrooted(current)))
69920 + return 1;
69921 +
69922 + rcu_read_lock();
69923 + read_lock(&tasklist_lock);
69924 +
69925 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
69926 + starttime = p->start_time.tv_sec;
69927 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
69928 + if (have_same_root(current, p)) {
69929 + goto allow;
69930 + } else {
69931 + read_unlock(&tasklist_lock);
69932 + rcu_read_unlock();
69933 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69934 + return 0;
69935 + }
69936 + }
69937 + /* creator exited, pid reuse, fall through to next check */
69938 + }
69939 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
69940 + if (unlikely(!have_same_root(current, p))) {
69941 + read_unlock(&tasklist_lock);
69942 + rcu_read_unlock();
69943 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69944 + return 0;
69945 + }
69946 + }
69947 +
69948 +allow:
69949 + read_unlock(&tasklist_lock);
69950 + rcu_read_unlock();
69951 +#endif
69952 + return 1;
69953 +}
69954 +
69955 +void
69956 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
69957 +{
69958 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69959 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
69960 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
69961 +#endif
69962 + return;
69963 +}
69964 +
69965 +int
69966 +gr_handle_chroot_mknod(const struct dentry *dentry,
69967 + const struct vfsmount *mnt, const int mode)
69968 +{
69969 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69970 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
69971 + proc_is_chrooted(current)) {
69972 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
69973 + return -EPERM;
69974 + }
69975 +#endif
69976 + return 0;
69977 +}
69978 +
69979 +int
69980 +gr_handle_chroot_mount(const struct dentry *dentry,
69981 + const struct vfsmount *mnt, const char *dev_name)
69982 +{
69983 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69984 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
69985 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
69986 + return -EPERM;
69987 + }
69988 +#endif
69989 + return 0;
69990 +}
69991 +
69992 +int
69993 +gr_handle_chroot_pivot(void)
69994 +{
69995 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69996 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
69997 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
69998 + return -EPERM;
69999 + }
70000 +#endif
70001 + return 0;
70002 +}
70003 +
70004 +int
70005 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
70006 +{
70007 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70008 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
70009 + !gr_is_outside_chroot(dentry, mnt)) {
70010 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
70011 + return -EPERM;
70012 + }
70013 +#endif
70014 + return 0;
70015 +}
70016 +
70017 +extern const char *captab_log[];
70018 +extern int captab_log_entries;
70019 +
70020 +int
70021 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70022 +{
70023 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70024 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70025 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70026 + if (cap_raised(chroot_caps, cap)) {
70027 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
70028 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
70029 + }
70030 + return 0;
70031 + }
70032 + }
70033 +#endif
70034 + return 1;
70035 +}
70036 +
70037 +int
70038 +gr_chroot_is_capable(const int cap)
70039 +{
70040 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70041 + return gr_task_chroot_is_capable(current, current_cred(), cap);
70042 +#endif
70043 + return 1;
70044 +}
70045 +
70046 +int
70047 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
70048 +{
70049 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70050 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70051 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70052 + if (cap_raised(chroot_caps, cap)) {
70053 + return 0;
70054 + }
70055 + }
70056 +#endif
70057 + return 1;
70058 +}
70059 +
70060 +int
70061 +gr_chroot_is_capable_nolog(const int cap)
70062 +{
70063 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70064 + return gr_task_chroot_is_capable_nolog(current, cap);
70065 +#endif
70066 + return 1;
70067 +}
70068 +
70069 +int
70070 +gr_handle_chroot_sysctl(const int op)
70071 +{
70072 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70073 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
70074 + proc_is_chrooted(current))
70075 + return -EACCES;
70076 +#endif
70077 + return 0;
70078 +}
70079 +
70080 +void
70081 +gr_handle_chroot_chdir(const struct path *path)
70082 +{
70083 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70084 + if (grsec_enable_chroot_chdir)
70085 + set_fs_pwd(current->fs, path);
70086 +#endif
70087 + return;
70088 +}
70089 +
70090 +int
70091 +gr_handle_chroot_chmod(const struct dentry *dentry,
70092 + const struct vfsmount *mnt, const int mode)
70093 +{
70094 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70095 + /* allow chmod +s on directories, but not files */
70096 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
70097 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
70098 + proc_is_chrooted(current)) {
70099 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
70100 + return -EPERM;
70101 + }
70102 +#endif
70103 + return 0;
70104 +}
70105 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
70106 new file mode 100644
70107 index 0000000..ce65ceb
70108 --- /dev/null
70109 +++ b/grsecurity/grsec_disabled.c
70110 @@ -0,0 +1,434 @@
70111 +#include <linux/kernel.h>
70112 +#include <linux/module.h>
70113 +#include <linux/sched.h>
70114 +#include <linux/file.h>
70115 +#include <linux/fs.h>
70116 +#include <linux/kdev_t.h>
70117 +#include <linux/net.h>
70118 +#include <linux/in.h>
70119 +#include <linux/ip.h>
70120 +#include <linux/skbuff.h>
70121 +#include <linux/sysctl.h>
70122 +
70123 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70124 +void
70125 +pax_set_initial_flags(struct linux_binprm *bprm)
70126 +{
70127 + return;
70128 +}
70129 +#endif
70130 +
70131 +#ifdef CONFIG_SYSCTL
70132 +__u32
70133 +gr_handle_sysctl(const struct ctl_table * table, const int op)
70134 +{
70135 + return 0;
70136 +}
70137 +#endif
70138 +
70139 +#ifdef CONFIG_TASKSTATS
70140 +int gr_is_taskstats_denied(int pid)
70141 +{
70142 + return 0;
70143 +}
70144 +#endif
70145 +
70146 +int
70147 +gr_acl_is_enabled(void)
70148 +{
70149 + return 0;
70150 +}
70151 +
70152 +void
70153 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
70154 +{
70155 + return;
70156 +}
70157 +
70158 +int
70159 +gr_handle_rawio(const struct inode *inode)
70160 +{
70161 + return 0;
70162 +}
70163 +
70164 +void
70165 +gr_acl_handle_psacct(struct task_struct *task, const long code)
70166 +{
70167 + return;
70168 +}
70169 +
70170 +int
70171 +gr_handle_ptrace(struct task_struct *task, const long request)
70172 +{
70173 + return 0;
70174 +}
70175 +
70176 +int
70177 +gr_handle_proc_ptrace(struct task_struct *task)
70178 +{
70179 + return 0;
70180 +}
70181 +
70182 +int
70183 +gr_set_acls(const int type)
70184 +{
70185 + return 0;
70186 +}
70187 +
70188 +int
70189 +gr_check_hidden_task(const struct task_struct *tsk)
70190 +{
70191 + return 0;
70192 +}
70193 +
70194 +int
70195 +gr_check_protected_task(const struct task_struct *task)
70196 +{
70197 + return 0;
70198 +}
70199 +
70200 +int
70201 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
70202 +{
70203 + return 0;
70204 +}
70205 +
70206 +void
70207 +gr_copy_label(struct task_struct *tsk)
70208 +{
70209 + return;
70210 +}
70211 +
70212 +void
70213 +gr_set_pax_flags(struct task_struct *task)
70214 +{
70215 + return;
70216 +}
70217 +
70218 +int
70219 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
70220 + const int unsafe_share)
70221 +{
70222 + return 0;
70223 +}
70224 +
70225 +void
70226 +gr_handle_delete(const ino_t ino, const dev_t dev)
70227 +{
70228 + return;
70229 +}
70230 +
70231 +void
70232 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
70233 +{
70234 + return;
70235 +}
70236 +
70237 +void
70238 +gr_handle_crash(struct task_struct *task, const int sig)
70239 +{
70240 + return;
70241 +}
70242 +
70243 +int
70244 +gr_check_crash_exec(const struct file *filp)
70245 +{
70246 + return 0;
70247 +}
70248 +
70249 +int
70250 +gr_check_crash_uid(const kuid_t uid)
70251 +{
70252 + return 0;
70253 +}
70254 +
70255 +void
70256 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70257 + struct dentry *old_dentry,
70258 + struct dentry *new_dentry,
70259 + struct vfsmount *mnt, const __u8 replace)
70260 +{
70261 + return;
70262 +}
70263 +
70264 +int
70265 +gr_search_socket(const int family, const int type, const int protocol)
70266 +{
70267 + return 1;
70268 +}
70269 +
70270 +int
70271 +gr_search_connectbind(const int mode, const struct socket *sock,
70272 + const struct sockaddr_in *addr)
70273 +{
70274 + return 0;
70275 +}
70276 +
70277 +void
70278 +gr_handle_alertkill(struct task_struct *task)
70279 +{
70280 + return;
70281 +}
70282 +
70283 +__u32
70284 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
70285 +{
70286 + return 1;
70287 +}
70288 +
70289 +__u32
70290 +gr_acl_handle_hidden_file(const struct dentry * dentry,
70291 + const struct vfsmount * mnt)
70292 +{
70293 + return 1;
70294 +}
70295 +
70296 +__u32
70297 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
70298 + int acc_mode)
70299 +{
70300 + return 1;
70301 +}
70302 +
70303 +__u32
70304 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70305 +{
70306 + return 1;
70307 +}
70308 +
70309 +__u32
70310 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
70311 +{
70312 + return 1;
70313 +}
70314 +
70315 +int
70316 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
70317 + unsigned int *vm_flags)
70318 +{
70319 + return 1;
70320 +}
70321 +
70322 +__u32
70323 +gr_acl_handle_truncate(const struct dentry * dentry,
70324 + const struct vfsmount * mnt)
70325 +{
70326 + return 1;
70327 +}
70328 +
70329 +__u32
70330 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
70331 +{
70332 + return 1;
70333 +}
70334 +
70335 +__u32
70336 +gr_acl_handle_access(const struct dentry * dentry,
70337 + const struct vfsmount * mnt, const int fmode)
70338 +{
70339 + return 1;
70340 +}
70341 +
70342 +__u32
70343 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
70344 + umode_t *mode)
70345 +{
70346 + return 1;
70347 +}
70348 +
70349 +__u32
70350 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
70351 +{
70352 + return 1;
70353 +}
70354 +
70355 +__u32
70356 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
70357 +{
70358 + return 1;
70359 +}
70360 +
70361 +void
70362 +grsecurity_init(void)
70363 +{
70364 + return;
70365 +}
70366 +
70367 +umode_t gr_acl_umask(void)
70368 +{
70369 + return 0;
70370 +}
70371 +
70372 +__u32
70373 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70374 + const struct dentry * parent_dentry,
70375 + const struct vfsmount * parent_mnt,
70376 + const int mode)
70377 +{
70378 + return 1;
70379 +}
70380 +
70381 +__u32
70382 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
70383 + const struct dentry * parent_dentry,
70384 + const struct vfsmount * parent_mnt)
70385 +{
70386 + return 1;
70387 +}
70388 +
70389 +__u32
70390 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70391 + const struct dentry * parent_dentry,
70392 + const struct vfsmount * parent_mnt, const struct filename *from)
70393 +{
70394 + return 1;
70395 +}
70396 +
70397 +__u32
70398 +gr_acl_handle_link(const struct dentry * new_dentry,
70399 + const struct dentry * parent_dentry,
70400 + const struct vfsmount * parent_mnt,
70401 + const struct dentry * old_dentry,
70402 + const struct vfsmount * old_mnt, const struct filename *to)
70403 +{
70404 + return 1;
70405 +}
70406 +
70407 +int
70408 +gr_acl_handle_rename(const struct dentry *new_dentry,
70409 + const struct dentry *parent_dentry,
70410 + const struct vfsmount *parent_mnt,
70411 + const struct dentry *old_dentry,
70412 + const struct inode *old_parent_inode,
70413 + const struct vfsmount *old_mnt, const struct filename *newname)
70414 +{
70415 + return 0;
70416 +}
70417 +
70418 +int
70419 +gr_acl_handle_filldir(const struct file *file, const char *name,
70420 + const int namelen, const ino_t ino)
70421 +{
70422 + return 1;
70423 +}
70424 +
70425 +int
70426 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70427 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70428 +{
70429 + return 1;
70430 +}
70431 +
70432 +int
70433 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
70434 +{
70435 + return 0;
70436 +}
70437 +
70438 +int
70439 +gr_search_accept(const struct socket *sock)
70440 +{
70441 + return 0;
70442 +}
70443 +
70444 +int
70445 +gr_search_listen(const struct socket *sock)
70446 +{
70447 + return 0;
70448 +}
70449 +
70450 +int
70451 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
70452 +{
70453 + return 0;
70454 +}
70455 +
70456 +__u32
70457 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
70458 +{
70459 + return 1;
70460 +}
70461 +
70462 +__u32
70463 +gr_acl_handle_creat(const struct dentry * dentry,
70464 + const struct dentry * p_dentry,
70465 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
70466 + const int imode)
70467 +{
70468 + return 1;
70469 +}
70470 +
70471 +void
70472 +gr_acl_handle_exit(void)
70473 +{
70474 + return;
70475 +}
70476 +
70477 +int
70478 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
70479 +{
70480 + return 1;
70481 +}
70482 +
70483 +void
70484 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
70485 +{
70486 + return;
70487 +}
70488 +
70489 +int
70490 +gr_acl_handle_procpidmem(const struct task_struct *task)
70491 +{
70492 + return 0;
70493 +}
70494 +
70495 +int
70496 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
70497 +{
70498 + return 0;
70499 +}
70500 +
70501 +int
70502 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70503 +{
70504 + return 0;
70505 +}
70506 +
70507 +void
70508 +gr_set_kernel_label(struct task_struct *task)
70509 +{
70510 + return;
70511 +}
70512 +
70513 +int
70514 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70515 +{
70516 + return 0;
70517 +}
70518 +
70519 +int
70520 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70521 +{
70522 + return 0;
70523 +}
70524 +
70525 +int gr_acl_enable_at_secure(void)
70526 +{
70527 + return 0;
70528 +}
70529 +
70530 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70531 +{
70532 + return dentry->d_sb->s_dev;
70533 +}
70534 +
70535 +void gr_put_exec_file(struct task_struct *task)
70536 +{
70537 + return;
70538 +}
70539 +
70540 +EXPORT_SYMBOL(gr_set_kernel_label);
70541 +#ifdef CONFIG_SECURITY
70542 +EXPORT_SYMBOL(gr_check_user_change);
70543 +EXPORT_SYMBOL(gr_check_group_change);
70544 +#endif
70545 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70546 new file mode 100644
70547 index 0000000..387032b
70548 --- /dev/null
70549 +++ b/grsecurity/grsec_exec.c
70550 @@ -0,0 +1,187 @@
70551 +#include <linux/kernel.h>
70552 +#include <linux/sched.h>
70553 +#include <linux/file.h>
70554 +#include <linux/binfmts.h>
70555 +#include <linux/fs.h>
70556 +#include <linux/types.h>
70557 +#include <linux/grdefs.h>
70558 +#include <linux/grsecurity.h>
70559 +#include <linux/grinternal.h>
70560 +#include <linux/capability.h>
70561 +#include <linux/module.h>
70562 +#include <linux/compat.h>
70563 +
70564 +#include <asm/uaccess.h>
70565 +
70566 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70567 +static char gr_exec_arg_buf[132];
70568 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70569 +#endif
70570 +
70571 +struct user_arg_ptr {
70572 +#ifdef CONFIG_COMPAT
70573 + bool is_compat;
70574 +#endif
70575 + union {
70576 + const char __user *const __user *native;
70577 +#ifdef CONFIG_COMPAT
70578 + const compat_uptr_t __user *compat;
70579 +#endif
70580 + } ptr;
70581 +};
70582 +
70583 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70584 +
70585 +void
70586 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70587 +{
70588 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70589 + char *grarg = gr_exec_arg_buf;
70590 + unsigned int i, x, execlen = 0;
70591 + char c;
70592 +
70593 + if (!((grsec_enable_execlog && grsec_enable_group &&
70594 + in_group_p(grsec_audit_gid))
70595 + || (grsec_enable_execlog && !grsec_enable_group)))
70596 + return;
70597 +
70598 + mutex_lock(&gr_exec_arg_mutex);
70599 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70600 +
70601 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70602 + const char __user *p;
70603 + unsigned int len;
70604 +
70605 + p = get_user_arg_ptr(argv, i);
70606 + if (IS_ERR(p))
70607 + goto log;
70608 +
70609 + len = strnlen_user(p, 128 - execlen);
70610 + if (len > 128 - execlen)
70611 + len = 128 - execlen;
70612 + else if (len > 0)
70613 + len--;
70614 + if (copy_from_user(grarg + execlen, p, len))
70615 + goto log;
70616 +
70617 + /* rewrite unprintable characters */
70618 + for (x = 0; x < len; x++) {
70619 + c = *(grarg + execlen + x);
70620 + if (c < 32 || c > 126)
70621 + *(grarg + execlen + x) = ' ';
70622 + }
70623 +
70624 + execlen += len;
70625 + *(grarg + execlen) = ' ';
70626 + *(grarg + execlen + 1) = '\0';
70627 + execlen++;
70628 + }
70629 +
70630 + log:
70631 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70632 + bprm->file->f_path.mnt, grarg);
70633 + mutex_unlock(&gr_exec_arg_mutex);
70634 +#endif
70635 + return;
70636 +}
70637 +
70638 +#ifdef CONFIG_GRKERNSEC
70639 +extern int gr_acl_is_capable(const int cap);
70640 +extern int gr_acl_is_capable_nolog(const int cap);
70641 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70642 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70643 +extern int gr_chroot_is_capable(const int cap);
70644 +extern int gr_chroot_is_capable_nolog(const int cap);
70645 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70646 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70647 +#endif
70648 +
70649 +const char *captab_log[] = {
70650 + "CAP_CHOWN",
70651 + "CAP_DAC_OVERRIDE",
70652 + "CAP_DAC_READ_SEARCH",
70653 + "CAP_FOWNER",
70654 + "CAP_FSETID",
70655 + "CAP_KILL",
70656 + "CAP_SETGID",
70657 + "CAP_SETUID",
70658 + "CAP_SETPCAP",
70659 + "CAP_LINUX_IMMUTABLE",
70660 + "CAP_NET_BIND_SERVICE",
70661 + "CAP_NET_BROADCAST",
70662 + "CAP_NET_ADMIN",
70663 + "CAP_NET_RAW",
70664 + "CAP_IPC_LOCK",
70665 + "CAP_IPC_OWNER",
70666 + "CAP_SYS_MODULE",
70667 + "CAP_SYS_RAWIO",
70668 + "CAP_SYS_CHROOT",
70669 + "CAP_SYS_PTRACE",
70670 + "CAP_SYS_PACCT",
70671 + "CAP_SYS_ADMIN",
70672 + "CAP_SYS_BOOT",
70673 + "CAP_SYS_NICE",
70674 + "CAP_SYS_RESOURCE",
70675 + "CAP_SYS_TIME",
70676 + "CAP_SYS_TTY_CONFIG",
70677 + "CAP_MKNOD",
70678 + "CAP_LEASE",
70679 + "CAP_AUDIT_WRITE",
70680 + "CAP_AUDIT_CONTROL",
70681 + "CAP_SETFCAP",
70682 + "CAP_MAC_OVERRIDE",
70683 + "CAP_MAC_ADMIN",
70684 + "CAP_SYSLOG",
70685 + "CAP_WAKE_ALARM"
70686 +};
70687 +
70688 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70689 +
70690 +int gr_is_capable(const int cap)
70691 +{
70692 +#ifdef CONFIG_GRKERNSEC
70693 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70694 + return 1;
70695 + return 0;
70696 +#else
70697 + return 1;
70698 +#endif
70699 +}
70700 +
70701 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70702 +{
70703 +#ifdef CONFIG_GRKERNSEC
70704 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70705 + return 1;
70706 + return 0;
70707 +#else
70708 + return 1;
70709 +#endif
70710 +}
70711 +
70712 +int gr_is_capable_nolog(const int cap)
70713 +{
70714 +#ifdef CONFIG_GRKERNSEC
70715 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70716 + return 1;
70717 + return 0;
70718 +#else
70719 + return 1;
70720 +#endif
70721 +}
70722 +
70723 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70724 +{
70725 +#ifdef CONFIG_GRKERNSEC
70726 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70727 + return 1;
70728 + return 0;
70729 +#else
70730 + return 1;
70731 +#endif
70732 +}
70733 +
70734 +EXPORT_SYMBOL(gr_is_capable);
70735 +EXPORT_SYMBOL(gr_is_capable_nolog);
70736 +EXPORT_SYMBOL(gr_task_is_capable);
70737 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70738 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70739 new file mode 100644
70740 index 0000000..06cc6ea
70741 --- /dev/null
70742 +++ b/grsecurity/grsec_fifo.c
70743 @@ -0,0 +1,24 @@
70744 +#include <linux/kernel.h>
70745 +#include <linux/sched.h>
70746 +#include <linux/fs.h>
70747 +#include <linux/file.h>
70748 +#include <linux/grinternal.h>
70749 +
70750 +int
70751 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70752 + const struct dentry *dir, const int flag, const int acc_mode)
70753 +{
70754 +#ifdef CONFIG_GRKERNSEC_FIFO
70755 + const struct cred *cred = current_cred();
70756 +
70757 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70758 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70759 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70760 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70761 + if (!inode_permission(dentry->d_inode, acc_mode))
70762 + 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));
70763 + return -EACCES;
70764 + }
70765 +#endif
70766 + return 0;
70767 +}
70768 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70769 new file mode 100644
70770 index 0000000..8ca18bf
70771 --- /dev/null
70772 +++ b/grsecurity/grsec_fork.c
70773 @@ -0,0 +1,23 @@
70774 +#include <linux/kernel.h>
70775 +#include <linux/sched.h>
70776 +#include <linux/grsecurity.h>
70777 +#include <linux/grinternal.h>
70778 +#include <linux/errno.h>
70779 +
70780 +void
70781 +gr_log_forkfail(const int retval)
70782 +{
70783 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70784 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70785 + switch (retval) {
70786 + case -EAGAIN:
70787 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70788 + break;
70789 + case -ENOMEM:
70790 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70791 + break;
70792 + }
70793 + }
70794 +#endif
70795 + return;
70796 +}
70797 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70798 new file mode 100644
70799 index 0000000..99a0cb9
70800 --- /dev/null
70801 +++ b/grsecurity/grsec_init.c
70802 @@ -0,0 +1,283 @@
70803 +#include <linux/kernel.h>
70804 +#include <linux/sched.h>
70805 +#include <linux/mm.h>
70806 +#include <linux/gracl.h>
70807 +#include <linux/slab.h>
70808 +#include <linux/vmalloc.h>
70809 +#include <linux/percpu.h>
70810 +#include <linux/module.h>
70811 +
70812 +int grsec_enable_ptrace_readexec;
70813 +int grsec_enable_setxid;
70814 +int grsec_enable_symlinkown;
70815 +kgid_t grsec_symlinkown_gid;
70816 +int grsec_enable_brute;
70817 +int grsec_enable_link;
70818 +int grsec_enable_dmesg;
70819 +int grsec_enable_harden_ptrace;
70820 +int grsec_enable_fifo;
70821 +int grsec_enable_execlog;
70822 +int grsec_enable_signal;
70823 +int grsec_enable_forkfail;
70824 +int grsec_enable_audit_ptrace;
70825 +int grsec_enable_time;
70826 +int grsec_enable_group;
70827 +kgid_t grsec_audit_gid;
70828 +int grsec_enable_chdir;
70829 +int grsec_enable_mount;
70830 +int grsec_enable_rofs;
70831 +int grsec_deny_new_usb;
70832 +int grsec_enable_chroot_findtask;
70833 +int grsec_enable_chroot_mount;
70834 +int grsec_enable_chroot_shmat;
70835 +int grsec_enable_chroot_fchdir;
70836 +int grsec_enable_chroot_double;
70837 +int grsec_enable_chroot_pivot;
70838 +int grsec_enable_chroot_chdir;
70839 +int grsec_enable_chroot_chmod;
70840 +int grsec_enable_chroot_mknod;
70841 +int grsec_enable_chroot_nice;
70842 +int grsec_enable_chroot_execlog;
70843 +int grsec_enable_chroot_caps;
70844 +int grsec_enable_chroot_sysctl;
70845 +int grsec_enable_chroot_unix;
70846 +int grsec_enable_tpe;
70847 +kgid_t grsec_tpe_gid;
70848 +int grsec_enable_blackhole;
70849 +#ifdef CONFIG_IPV6_MODULE
70850 +EXPORT_SYMBOL(grsec_enable_blackhole);
70851 +#endif
70852 +int grsec_lastack_retries;
70853 +int grsec_enable_tpe_all;
70854 +int grsec_enable_tpe_invert;
70855 +int grsec_enable_socket_all;
70856 +kgid_t grsec_socket_all_gid;
70857 +int grsec_enable_socket_client;
70858 +kgid_t grsec_socket_client_gid;
70859 +int grsec_enable_socket_server;
70860 +kgid_t grsec_socket_server_gid;
70861 +int grsec_resource_logging;
70862 +int grsec_disable_privio;
70863 +int grsec_enable_log_rwxmaps;
70864 +int grsec_lock;
70865 +
70866 +DEFINE_SPINLOCK(grsec_alert_lock);
70867 +unsigned long grsec_alert_wtime = 0;
70868 +unsigned long grsec_alert_fyet = 0;
70869 +
70870 +DEFINE_SPINLOCK(grsec_audit_lock);
70871 +
70872 +DEFINE_RWLOCK(grsec_exec_file_lock);
70873 +
70874 +char *gr_shared_page[4];
70875 +
70876 +char *gr_alert_log_fmt;
70877 +char *gr_audit_log_fmt;
70878 +char *gr_alert_log_buf;
70879 +char *gr_audit_log_buf;
70880 +
70881 +extern struct gr_arg *gr_usermode;
70882 +extern unsigned char *gr_system_salt;
70883 +extern unsigned char *gr_system_sum;
70884 +
70885 +void __init
70886 +grsecurity_init(void)
70887 +{
70888 + int j;
70889 + /* create the per-cpu shared pages */
70890 +
70891 +#ifdef CONFIG_X86
70892 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
70893 +#endif
70894 +
70895 + for (j = 0; j < 4; j++) {
70896 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
70897 + if (gr_shared_page[j] == NULL) {
70898 + panic("Unable to allocate grsecurity shared page");
70899 + return;
70900 + }
70901 + }
70902 +
70903 + /* allocate log buffers */
70904 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
70905 + if (!gr_alert_log_fmt) {
70906 + panic("Unable to allocate grsecurity alert log format buffer");
70907 + return;
70908 + }
70909 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
70910 + if (!gr_audit_log_fmt) {
70911 + panic("Unable to allocate grsecurity audit log format buffer");
70912 + return;
70913 + }
70914 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70915 + if (!gr_alert_log_buf) {
70916 + panic("Unable to allocate grsecurity alert log buffer");
70917 + return;
70918 + }
70919 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70920 + if (!gr_audit_log_buf) {
70921 + panic("Unable to allocate grsecurity audit log buffer");
70922 + return;
70923 + }
70924 +
70925 + /* allocate memory for authentication structure */
70926 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
70927 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
70928 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
70929 +
70930 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
70931 + panic("Unable to allocate grsecurity authentication structure");
70932 + return;
70933 + }
70934 +
70935 +
70936 +#ifdef CONFIG_GRKERNSEC_IO
70937 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
70938 + grsec_disable_privio = 1;
70939 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70940 + grsec_disable_privio = 1;
70941 +#else
70942 + grsec_disable_privio = 0;
70943 +#endif
70944 +#endif
70945 +
70946 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70947 + /* for backward compatibility, tpe_invert always defaults to on if
70948 + enabled in the kernel
70949 + */
70950 + grsec_enable_tpe_invert = 1;
70951 +#endif
70952 +
70953 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70954 +#ifndef CONFIG_GRKERNSEC_SYSCTL
70955 + grsec_lock = 1;
70956 +#endif
70957 +
70958 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70959 + grsec_enable_log_rwxmaps = 1;
70960 +#endif
70961 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70962 + grsec_enable_group = 1;
70963 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
70964 +#endif
70965 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70966 + grsec_enable_ptrace_readexec = 1;
70967 +#endif
70968 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70969 + grsec_enable_chdir = 1;
70970 +#endif
70971 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70972 + grsec_enable_harden_ptrace = 1;
70973 +#endif
70974 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70975 + grsec_enable_mount = 1;
70976 +#endif
70977 +#ifdef CONFIG_GRKERNSEC_LINK
70978 + grsec_enable_link = 1;
70979 +#endif
70980 +#ifdef CONFIG_GRKERNSEC_BRUTE
70981 + grsec_enable_brute = 1;
70982 +#endif
70983 +#ifdef CONFIG_GRKERNSEC_DMESG
70984 + grsec_enable_dmesg = 1;
70985 +#endif
70986 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70987 + grsec_enable_blackhole = 1;
70988 + grsec_lastack_retries = 4;
70989 +#endif
70990 +#ifdef CONFIG_GRKERNSEC_FIFO
70991 + grsec_enable_fifo = 1;
70992 +#endif
70993 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70994 + grsec_enable_execlog = 1;
70995 +#endif
70996 +#ifdef CONFIG_GRKERNSEC_SETXID
70997 + grsec_enable_setxid = 1;
70998 +#endif
70999 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71000 + grsec_enable_signal = 1;
71001 +#endif
71002 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71003 + grsec_enable_forkfail = 1;
71004 +#endif
71005 +#ifdef CONFIG_GRKERNSEC_TIME
71006 + grsec_enable_time = 1;
71007 +#endif
71008 +#ifdef CONFIG_GRKERNSEC_RESLOG
71009 + grsec_resource_logging = 1;
71010 +#endif
71011 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71012 + grsec_enable_chroot_findtask = 1;
71013 +#endif
71014 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71015 + grsec_enable_chroot_unix = 1;
71016 +#endif
71017 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71018 + grsec_enable_chroot_mount = 1;
71019 +#endif
71020 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71021 + grsec_enable_chroot_fchdir = 1;
71022 +#endif
71023 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71024 + grsec_enable_chroot_shmat = 1;
71025 +#endif
71026 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71027 + grsec_enable_audit_ptrace = 1;
71028 +#endif
71029 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71030 + grsec_enable_chroot_double = 1;
71031 +#endif
71032 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71033 + grsec_enable_chroot_pivot = 1;
71034 +#endif
71035 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71036 + grsec_enable_chroot_chdir = 1;
71037 +#endif
71038 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71039 + grsec_enable_chroot_chmod = 1;
71040 +#endif
71041 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71042 + grsec_enable_chroot_mknod = 1;
71043 +#endif
71044 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71045 + grsec_enable_chroot_nice = 1;
71046 +#endif
71047 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71048 + grsec_enable_chroot_execlog = 1;
71049 +#endif
71050 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71051 + grsec_enable_chroot_caps = 1;
71052 +#endif
71053 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71054 + grsec_enable_chroot_sysctl = 1;
71055 +#endif
71056 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71057 + grsec_enable_symlinkown = 1;
71058 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
71059 +#endif
71060 +#ifdef CONFIG_GRKERNSEC_TPE
71061 + grsec_enable_tpe = 1;
71062 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
71063 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71064 + grsec_enable_tpe_all = 1;
71065 +#endif
71066 +#endif
71067 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71068 + grsec_enable_socket_all = 1;
71069 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
71070 +#endif
71071 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71072 + grsec_enable_socket_client = 1;
71073 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
71074 +#endif
71075 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71076 + grsec_enable_socket_server = 1;
71077 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
71078 +#endif
71079 +#endif
71080 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
71081 + grsec_deny_new_usb = 1;
71082 +#endif
71083 +
71084 + return;
71085 +}
71086 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
71087 new file mode 100644
71088 index 0000000..5e05e20
71089 --- /dev/null
71090 +++ b/grsecurity/grsec_link.c
71091 @@ -0,0 +1,58 @@
71092 +#include <linux/kernel.h>
71093 +#include <linux/sched.h>
71094 +#include <linux/fs.h>
71095 +#include <linux/file.h>
71096 +#include <linux/grinternal.h>
71097 +
71098 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
71099 +{
71100 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71101 + const struct inode *link_inode = link->dentry->d_inode;
71102 +
71103 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
71104 + /* ignore root-owned links, e.g. /proc/self */
71105 + gr_is_global_nonroot(link_inode->i_uid) && target &&
71106 + !uid_eq(link_inode->i_uid, target->i_uid)) {
71107 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
71108 + return 1;
71109 + }
71110 +#endif
71111 + return 0;
71112 +}
71113 +
71114 +int
71115 +gr_handle_follow_link(const struct inode *parent,
71116 + const struct inode *inode,
71117 + const struct dentry *dentry, const struct vfsmount *mnt)
71118 +{
71119 +#ifdef CONFIG_GRKERNSEC_LINK
71120 + const struct cred *cred = current_cred();
71121 +
71122 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
71123 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
71124 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
71125 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
71126 + return -EACCES;
71127 + }
71128 +#endif
71129 + return 0;
71130 +}
71131 +
71132 +int
71133 +gr_handle_hardlink(const struct dentry *dentry,
71134 + const struct vfsmount *mnt,
71135 + struct inode *inode, const int mode, const struct filename *to)
71136 +{
71137 +#ifdef CONFIG_GRKERNSEC_LINK
71138 + const struct cred *cred = current_cred();
71139 +
71140 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
71141 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
71142 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
71143 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
71144 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
71145 + return -EPERM;
71146 + }
71147 +#endif
71148 + return 0;
71149 +}
71150 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
71151 new file mode 100644
71152 index 0000000..dbe0a6b
71153 --- /dev/null
71154 +++ b/grsecurity/grsec_log.c
71155 @@ -0,0 +1,341 @@
71156 +#include <linux/kernel.h>
71157 +#include <linux/sched.h>
71158 +#include <linux/file.h>
71159 +#include <linux/tty.h>
71160 +#include <linux/fs.h>
71161 +#include <linux/mm.h>
71162 +#include <linux/grinternal.h>
71163 +
71164 +#ifdef CONFIG_TREE_PREEMPT_RCU
71165 +#define DISABLE_PREEMPT() preempt_disable()
71166 +#define ENABLE_PREEMPT() preempt_enable()
71167 +#else
71168 +#define DISABLE_PREEMPT()
71169 +#define ENABLE_PREEMPT()
71170 +#endif
71171 +
71172 +#define BEGIN_LOCKS(x) \
71173 + DISABLE_PREEMPT(); \
71174 + rcu_read_lock(); \
71175 + read_lock(&tasklist_lock); \
71176 + read_lock(&grsec_exec_file_lock); \
71177 + if (x != GR_DO_AUDIT) \
71178 + spin_lock(&grsec_alert_lock); \
71179 + else \
71180 + spin_lock(&grsec_audit_lock)
71181 +
71182 +#define END_LOCKS(x) \
71183 + if (x != GR_DO_AUDIT) \
71184 + spin_unlock(&grsec_alert_lock); \
71185 + else \
71186 + spin_unlock(&grsec_audit_lock); \
71187 + read_unlock(&grsec_exec_file_lock); \
71188 + read_unlock(&tasklist_lock); \
71189 + rcu_read_unlock(); \
71190 + ENABLE_PREEMPT(); \
71191 + if (x == GR_DONT_AUDIT) \
71192 + gr_handle_alertkill(current)
71193 +
71194 +enum {
71195 + FLOODING,
71196 + NO_FLOODING
71197 +};
71198 +
71199 +extern char *gr_alert_log_fmt;
71200 +extern char *gr_audit_log_fmt;
71201 +extern char *gr_alert_log_buf;
71202 +extern char *gr_audit_log_buf;
71203 +
71204 +static int gr_log_start(int audit)
71205 +{
71206 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
71207 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
71208 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71209 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
71210 + unsigned long curr_secs = get_seconds();
71211 +
71212 + if (audit == GR_DO_AUDIT)
71213 + goto set_fmt;
71214 +
71215 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
71216 + grsec_alert_wtime = curr_secs;
71217 + grsec_alert_fyet = 0;
71218 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
71219 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
71220 + grsec_alert_fyet++;
71221 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
71222 + grsec_alert_wtime = curr_secs;
71223 + grsec_alert_fyet++;
71224 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
71225 + return FLOODING;
71226 + }
71227 + else return FLOODING;
71228 +
71229 +set_fmt:
71230 +#endif
71231 + memset(buf, 0, PAGE_SIZE);
71232 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
71233 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
71234 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71235 + } else if (current->signal->curr_ip) {
71236 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
71237 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
71238 + } else if (gr_acl_is_enabled()) {
71239 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
71240 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71241 + } else {
71242 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
71243 + strcpy(buf, fmt);
71244 + }
71245 +
71246 + return NO_FLOODING;
71247 +}
71248 +
71249 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71250 + __attribute__ ((format (printf, 2, 0)));
71251 +
71252 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71253 +{
71254 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71255 + unsigned int len = strlen(buf);
71256 +
71257 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71258 +
71259 + return;
71260 +}
71261 +
71262 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71263 + __attribute__ ((format (printf, 2, 3)));
71264 +
71265 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71266 +{
71267 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71268 + unsigned int len = strlen(buf);
71269 + va_list ap;
71270 +
71271 + va_start(ap, msg);
71272 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71273 + va_end(ap);
71274 +
71275 + return;
71276 +}
71277 +
71278 +static void gr_log_end(int audit, int append_default)
71279 +{
71280 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71281 + if (append_default) {
71282 + struct task_struct *task = current;
71283 + struct task_struct *parent = task->real_parent;
71284 + const struct cred *cred = __task_cred(task);
71285 + const struct cred *pcred = __task_cred(parent);
71286 + unsigned int len = strlen(buf);
71287 +
71288 + 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));
71289 + }
71290 +
71291 + printk("%s\n", buf);
71292 +
71293 + return;
71294 +}
71295 +
71296 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
71297 +{
71298 + int logtype;
71299 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
71300 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
71301 + void *voidptr = NULL;
71302 + int num1 = 0, num2 = 0;
71303 + unsigned long ulong1 = 0, ulong2 = 0;
71304 + struct dentry *dentry = NULL;
71305 + struct vfsmount *mnt = NULL;
71306 + struct file *file = NULL;
71307 + struct task_struct *task = NULL;
71308 + struct vm_area_struct *vma = NULL;
71309 + const struct cred *cred, *pcred;
71310 + va_list ap;
71311 +
71312 + BEGIN_LOCKS(audit);
71313 + logtype = gr_log_start(audit);
71314 + if (logtype == FLOODING) {
71315 + END_LOCKS(audit);
71316 + return;
71317 + }
71318 + va_start(ap, argtypes);
71319 + switch (argtypes) {
71320 + case GR_TTYSNIFF:
71321 + task = va_arg(ap, struct task_struct *);
71322 + 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));
71323 + break;
71324 + case GR_SYSCTL_HIDDEN:
71325 + str1 = va_arg(ap, char *);
71326 + gr_log_middle_varargs(audit, msg, result, str1);
71327 + break;
71328 + case GR_RBAC:
71329 + dentry = va_arg(ap, struct dentry *);
71330 + mnt = va_arg(ap, struct vfsmount *);
71331 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
71332 + break;
71333 + case GR_RBAC_STR:
71334 + dentry = va_arg(ap, struct dentry *);
71335 + mnt = va_arg(ap, struct vfsmount *);
71336 + str1 = va_arg(ap, char *);
71337 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
71338 + break;
71339 + case GR_STR_RBAC:
71340 + str1 = va_arg(ap, char *);
71341 + dentry = va_arg(ap, struct dentry *);
71342 + mnt = va_arg(ap, struct vfsmount *);
71343 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
71344 + break;
71345 + case GR_RBAC_MODE2:
71346 + dentry = va_arg(ap, struct dentry *);
71347 + mnt = va_arg(ap, struct vfsmount *);
71348 + str1 = va_arg(ap, char *);
71349 + str2 = va_arg(ap, char *);
71350 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
71351 + break;
71352 + case GR_RBAC_MODE3:
71353 + dentry = va_arg(ap, struct dentry *);
71354 + mnt = va_arg(ap, struct vfsmount *);
71355 + str1 = va_arg(ap, char *);
71356 + str2 = va_arg(ap, char *);
71357 + str3 = va_arg(ap, char *);
71358 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
71359 + break;
71360 + case GR_FILENAME:
71361 + dentry = va_arg(ap, struct dentry *);
71362 + mnt = va_arg(ap, struct vfsmount *);
71363 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
71364 + break;
71365 + case GR_STR_FILENAME:
71366 + str1 = va_arg(ap, char *);
71367 + dentry = va_arg(ap, struct dentry *);
71368 + mnt = va_arg(ap, struct vfsmount *);
71369 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
71370 + break;
71371 + case GR_FILENAME_STR:
71372 + dentry = va_arg(ap, struct dentry *);
71373 + mnt = va_arg(ap, struct vfsmount *);
71374 + str1 = va_arg(ap, char *);
71375 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
71376 + break;
71377 + case GR_FILENAME_TWO_INT:
71378 + dentry = va_arg(ap, struct dentry *);
71379 + mnt = va_arg(ap, struct vfsmount *);
71380 + num1 = va_arg(ap, int);
71381 + num2 = va_arg(ap, int);
71382 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
71383 + break;
71384 + case GR_FILENAME_TWO_INT_STR:
71385 + dentry = va_arg(ap, struct dentry *);
71386 + mnt = va_arg(ap, struct vfsmount *);
71387 + num1 = va_arg(ap, int);
71388 + num2 = va_arg(ap, int);
71389 + str1 = va_arg(ap, char *);
71390 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
71391 + break;
71392 + case GR_TEXTREL:
71393 + file = va_arg(ap, struct file *);
71394 + ulong1 = va_arg(ap, unsigned long);
71395 + ulong2 = va_arg(ap, unsigned long);
71396 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
71397 + break;
71398 + case GR_PTRACE:
71399 + task = va_arg(ap, struct task_struct *);
71400 + 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));
71401 + break;
71402 + case GR_RESOURCE:
71403 + task = va_arg(ap, struct task_struct *);
71404 + cred = __task_cred(task);
71405 + pcred = __task_cred(task->real_parent);
71406 + ulong1 = va_arg(ap, unsigned long);
71407 + str1 = va_arg(ap, char *);
71408 + ulong2 = va_arg(ap, unsigned long);
71409 + 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));
71410 + break;
71411 + case GR_CAP:
71412 + task = va_arg(ap, struct task_struct *);
71413 + cred = __task_cred(task);
71414 + pcred = __task_cred(task->real_parent);
71415 + str1 = va_arg(ap, char *);
71416 + 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));
71417 + break;
71418 + case GR_SIG:
71419 + str1 = va_arg(ap, char *);
71420 + voidptr = va_arg(ap, void *);
71421 + gr_log_middle_varargs(audit, msg, str1, voidptr);
71422 + break;
71423 + case GR_SIG2:
71424 + task = va_arg(ap, struct task_struct *);
71425 + cred = __task_cred(task);
71426 + pcred = __task_cred(task->real_parent);
71427 + num1 = va_arg(ap, int);
71428 + 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));
71429 + break;
71430 + case GR_CRASH1:
71431 + task = va_arg(ap, struct task_struct *);
71432 + cred = __task_cred(task);
71433 + pcred = __task_cred(task->real_parent);
71434 + ulong1 = va_arg(ap, unsigned long);
71435 + 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);
71436 + break;
71437 + case GR_CRASH2:
71438 + task = va_arg(ap, struct task_struct *);
71439 + cred = __task_cred(task);
71440 + pcred = __task_cred(task->real_parent);
71441 + ulong1 = va_arg(ap, unsigned long);
71442 + 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);
71443 + break;
71444 + case GR_RWXMAP:
71445 + file = va_arg(ap, struct file *);
71446 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
71447 + break;
71448 + case GR_RWXMAPVMA:
71449 + vma = va_arg(ap, struct vm_area_struct *);
71450 + if (vma->vm_file)
71451 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
71452 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
71453 + str1 = "<stack>";
71454 + else if (vma->vm_start <= current->mm->brk &&
71455 + vma->vm_end >= current->mm->start_brk)
71456 + str1 = "<heap>";
71457 + else
71458 + str1 = "<anonymous mapping>";
71459 + gr_log_middle_varargs(audit, msg, str1);
71460 + break;
71461 + case GR_PSACCT:
71462 + {
71463 + unsigned int wday, cday;
71464 + __u8 whr, chr;
71465 + __u8 wmin, cmin;
71466 + __u8 wsec, csec;
71467 + char cur_tty[64] = { 0 };
71468 + char parent_tty[64] = { 0 };
71469 +
71470 + task = va_arg(ap, struct task_struct *);
71471 + wday = va_arg(ap, unsigned int);
71472 + cday = va_arg(ap, unsigned int);
71473 + whr = va_arg(ap, int);
71474 + chr = va_arg(ap, int);
71475 + wmin = va_arg(ap, int);
71476 + cmin = va_arg(ap, int);
71477 + wsec = va_arg(ap, int);
71478 + csec = va_arg(ap, int);
71479 + ulong1 = va_arg(ap, unsigned long);
71480 + cred = __task_cred(task);
71481 + pcred = __task_cred(task->real_parent);
71482 +
71483 + 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));
71484 + }
71485 + break;
71486 + default:
71487 + gr_log_middle(audit, msg, ap);
71488 + }
71489 + va_end(ap);
71490 + // these don't need DEFAULTSECARGS printed on the end
71491 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71492 + gr_log_end(audit, 0);
71493 + else
71494 + gr_log_end(audit, 1);
71495 + END_LOCKS(audit);
71496 +}
71497 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
71498 new file mode 100644
71499 index 0000000..f536303
71500 --- /dev/null
71501 +++ b/grsecurity/grsec_mem.c
71502 @@ -0,0 +1,40 @@
71503 +#include <linux/kernel.h>
71504 +#include <linux/sched.h>
71505 +#include <linux/mm.h>
71506 +#include <linux/mman.h>
71507 +#include <linux/grinternal.h>
71508 +
71509 +void
71510 +gr_handle_ioperm(void)
71511 +{
71512 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
71513 + return;
71514 +}
71515 +
71516 +void
71517 +gr_handle_iopl(void)
71518 +{
71519 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71520 + return;
71521 +}
71522 +
71523 +void
71524 +gr_handle_mem_readwrite(u64 from, u64 to)
71525 +{
71526 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71527 + return;
71528 +}
71529 +
71530 +void
71531 +gr_handle_vm86(void)
71532 +{
71533 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71534 + return;
71535 +}
71536 +
71537 +void
71538 +gr_log_badprocpid(const char *entry)
71539 +{
71540 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71541 + return;
71542 +}
71543 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71544 new file mode 100644
71545 index 0000000..2131422
71546 --- /dev/null
71547 +++ b/grsecurity/grsec_mount.c
71548 @@ -0,0 +1,62 @@
71549 +#include <linux/kernel.h>
71550 +#include <linux/sched.h>
71551 +#include <linux/mount.h>
71552 +#include <linux/grsecurity.h>
71553 +#include <linux/grinternal.h>
71554 +
71555 +void
71556 +gr_log_remount(const char *devname, const int retval)
71557 +{
71558 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71559 + if (grsec_enable_mount && (retval >= 0))
71560 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71561 +#endif
71562 + return;
71563 +}
71564 +
71565 +void
71566 +gr_log_unmount(const char *devname, const int retval)
71567 +{
71568 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71569 + if (grsec_enable_mount && (retval >= 0))
71570 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71571 +#endif
71572 + return;
71573 +}
71574 +
71575 +void
71576 +gr_log_mount(const char *from, const char *to, const int retval)
71577 +{
71578 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71579 + if (grsec_enable_mount && (retval >= 0))
71580 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71581 +#endif
71582 + return;
71583 +}
71584 +
71585 +int
71586 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71587 +{
71588 +#ifdef CONFIG_GRKERNSEC_ROFS
71589 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71590 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71591 + return -EPERM;
71592 + } else
71593 + return 0;
71594 +#endif
71595 + return 0;
71596 +}
71597 +
71598 +int
71599 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71600 +{
71601 +#ifdef CONFIG_GRKERNSEC_ROFS
71602 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71603 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71604 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71605 + return -EPERM;
71606 + } else
71607 + return 0;
71608 +#endif
71609 + return 0;
71610 +}
71611 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71612 new file mode 100644
71613 index 0000000..6ee9d50
71614 --- /dev/null
71615 +++ b/grsecurity/grsec_pax.c
71616 @@ -0,0 +1,45 @@
71617 +#include <linux/kernel.h>
71618 +#include <linux/sched.h>
71619 +#include <linux/mm.h>
71620 +#include <linux/file.h>
71621 +#include <linux/grinternal.h>
71622 +#include <linux/grsecurity.h>
71623 +
71624 +void
71625 +gr_log_textrel(struct vm_area_struct * vma)
71626 +{
71627 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71628 + if (grsec_enable_log_rwxmaps)
71629 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71630 +#endif
71631 + return;
71632 +}
71633 +
71634 +void gr_log_ptgnustack(struct file *file)
71635 +{
71636 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71637 + if (grsec_enable_log_rwxmaps)
71638 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71639 +#endif
71640 + return;
71641 +}
71642 +
71643 +void
71644 +gr_log_rwxmmap(struct file *file)
71645 +{
71646 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71647 + if (grsec_enable_log_rwxmaps)
71648 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71649 +#endif
71650 + return;
71651 +}
71652 +
71653 +void
71654 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71655 +{
71656 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71657 + if (grsec_enable_log_rwxmaps)
71658 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71659 +#endif
71660 + return;
71661 +}
71662 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71663 new file mode 100644
71664 index 0000000..f7f29aa
71665 --- /dev/null
71666 +++ b/grsecurity/grsec_ptrace.c
71667 @@ -0,0 +1,30 @@
71668 +#include <linux/kernel.h>
71669 +#include <linux/sched.h>
71670 +#include <linux/grinternal.h>
71671 +#include <linux/security.h>
71672 +
71673 +void
71674 +gr_audit_ptrace(struct task_struct *task)
71675 +{
71676 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71677 + if (grsec_enable_audit_ptrace)
71678 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71679 +#endif
71680 + return;
71681 +}
71682 +
71683 +int
71684 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71685 +{
71686 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71687 + const struct dentry *dentry = file->f_path.dentry;
71688 + const struct vfsmount *mnt = file->f_path.mnt;
71689 +
71690 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71691 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71692 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71693 + return -EACCES;
71694 + }
71695 +#endif
71696 + return 0;
71697 +}
71698 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71699 new file mode 100644
71700 index 0000000..4e29cc7
71701 --- /dev/null
71702 +++ b/grsecurity/grsec_sig.c
71703 @@ -0,0 +1,246 @@
71704 +#include <linux/kernel.h>
71705 +#include <linux/sched.h>
71706 +#include <linux/fs.h>
71707 +#include <linux/delay.h>
71708 +#include <linux/grsecurity.h>
71709 +#include <linux/grinternal.h>
71710 +#include <linux/hardirq.h>
71711 +
71712 +char *signames[] = {
71713 + [SIGSEGV] = "Segmentation fault",
71714 + [SIGILL] = "Illegal instruction",
71715 + [SIGABRT] = "Abort",
71716 + [SIGBUS] = "Invalid alignment/Bus error"
71717 +};
71718 +
71719 +void
71720 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71721 +{
71722 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71723 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71724 + (sig == SIGABRT) || (sig == SIGBUS))) {
71725 + if (task_pid_nr(t) == task_pid_nr(current)) {
71726 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71727 + } else {
71728 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71729 + }
71730 + }
71731 +#endif
71732 + return;
71733 +}
71734 +
71735 +int
71736 +gr_handle_signal(const struct task_struct *p, const int sig)
71737 +{
71738 +#ifdef CONFIG_GRKERNSEC
71739 + /* ignore the 0 signal for protected task checks */
71740 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71741 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71742 + return -EPERM;
71743 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71744 + return -EPERM;
71745 + }
71746 +#endif
71747 + return 0;
71748 +}
71749 +
71750 +#ifdef CONFIG_GRKERNSEC
71751 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71752 +
71753 +int gr_fake_force_sig(int sig, struct task_struct *t)
71754 +{
71755 + unsigned long int flags;
71756 + int ret, blocked, ignored;
71757 + struct k_sigaction *action;
71758 +
71759 + spin_lock_irqsave(&t->sighand->siglock, flags);
71760 + action = &t->sighand->action[sig-1];
71761 + ignored = action->sa.sa_handler == SIG_IGN;
71762 + blocked = sigismember(&t->blocked, sig);
71763 + if (blocked || ignored) {
71764 + action->sa.sa_handler = SIG_DFL;
71765 + if (blocked) {
71766 + sigdelset(&t->blocked, sig);
71767 + recalc_sigpending_and_wake(t);
71768 + }
71769 + }
71770 + if (action->sa.sa_handler == SIG_DFL)
71771 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71772 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71773 +
71774 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71775 +
71776 + return ret;
71777 +}
71778 +#endif
71779 +
71780 +#ifdef CONFIG_GRKERNSEC_BRUTE
71781 +#define GR_USER_BAN_TIME (15 * 60)
71782 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71783 +
71784 +static int __get_dumpable(unsigned long mm_flags)
71785 +{
71786 + int ret;
71787 +
71788 + ret = mm_flags & MMF_DUMPABLE_MASK;
71789 + return (ret >= 2) ? 2 : ret;
71790 +}
71791 +#endif
71792 +
71793 +void gr_handle_brute_attach(unsigned long mm_flags)
71794 +{
71795 +#ifdef CONFIG_GRKERNSEC_BRUTE
71796 + struct task_struct *p = current;
71797 + kuid_t uid = GLOBAL_ROOT_UID;
71798 + int daemon = 0;
71799 +
71800 + if (!grsec_enable_brute)
71801 + return;
71802 +
71803 + rcu_read_lock();
71804 + read_lock(&tasklist_lock);
71805 + read_lock(&grsec_exec_file_lock);
71806 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71807 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71808 + p->real_parent->brute = 1;
71809 + daemon = 1;
71810 + } else {
71811 + const struct cred *cred = __task_cred(p), *cred2;
71812 + struct task_struct *tsk, *tsk2;
71813 +
71814 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
71815 + struct user_struct *user;
71816 +
71817 + uid = cred->uid;
71818 +
71819 + /* this is put upon execution past expiration */
71820 + user = find_user(uid);
71821 + if (user == NULL)
71822 + goto unlock;
71823 + user->suid_banned = 1;
71824 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
71825 + if (user->suid_ban_expires == ~0UL)
71826 + user->suid_ban_expires--;
71827 +
71828 + /* only kill other threads of the same binary, from the same user */
71829 + do_each_thread(tsk2, tsk) {
71830 + cred2 = __task_cred(tsk);
71831 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
71832 + gr_fake_force_sig(SIGKILL, tsk);
71833 + } while_each_thread(tsk2, tsk);
71834 + }
71835 + }
71836 +unlock:
71837 + read_unlock(&grsec_exec_file_lock);
71838 + read_unlock(&tasklist_lock);
71839 + rcu_read_unlock();
71840 +
71841 + if (gr_is_global_nonroot(uid))
71842 + 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);
71843 + else if (daemon)
71844 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
71845 +
71846 +#endif
71847 + return;
71848 +}
71849 +
71850 +void gr_handle_brute_check(void)
71851 +{
71852 +#ifdef CONFIG_GRKERNSEC_BRUTE
71853 + struct task_struct *p = current;
71854 +
71855 + if (unlikely(p->brute)) {
71856 + if (!grsec_enable_brute)
71857 + p->brute = 0;
71858 + else if (time_before(get_seconds(), p->brute_expires))
71859 + msleep(30 * 1000);
71860 + }
71861 +#endif
71862 + return;
71863 +}
71864 +
71865 +void gr_handle_kernel_exploit(void)
71866 +{
71867 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71868 + const struct cred *cred;
71869 + struct task_struct *tsk, *tsk2;
71870 + struct user_struct *user;
71871 + kuid_t uid;
71872 +
71873 + if (in_irq() || in_serving_softirq() || in_nmi())
71874 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
71875 +
71876 + uid = current_uid();
71877 +
71878 + if (gr_is_global_root(uid))
71879 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
71880 + else {
71881 + /* kill all the processes of this user, hold a reference
71882 + to their creds struct, and prevent them from creating
71883 + another process until system reset
71884 + */
71885 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
71886 + GR_GLOBAL_UID(uid));
71887 + /* we intentionally leak this ref */
71888 + user = get_uid(current->cred->user);
71889 + if (user)
71890 + user->kernel_banned = 1;
71891 +
71892 + /* kill all processes of this user */
71893 + read_lock(&tasklist_lock);
71894 + do_each_thread(tsk2, tsk) {
71895 + cred = __task_cred(tsk);
71896 + if (uid_eq(cred->uid, uid))
71897 + gr_fake_force_sig(SIGKILL, tsk);
71898 + } while_each_thread(tsk2, tsk);
71899 + read_unlock(&tasklist_lock);
71900 + }
71901 +#endif
71902 +}
71903 +
71904 +#ifdef CONFIG_GRKERNSEC_BRUTE
71905 +static bool suid_ban_expired(struct user_struct *user)
71906 +{
71907 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
71908 + user->suid_banned = 0;
71909 + user->suid_ban_expires = 0;
71910 + free_uid(user);
71911 + return true;
71912 + }
71913 +
71914 + return false;
71915 +}
71916 +#endif
71917 +
71918 +int gr_process_kernel_exec_ban(void)
71919 +{
71920 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71921 + if (unlikely(current->cred->user->kernel_banned))
71922 + return -EPERM;
71923 +#endif
71924 + return 0;
71925 +}
71926 +
71927 +int gr_process_kernel_setuid_ban(struct user_struct *user)
71928 +{
71929 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71930 + if (unlikely(user->kernel_banned))
71931 + gr_fake_force_sig(SIGKILL, current);
71932 +#endif
71933 + return 0;
71934 +}
71935 +
71936 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
71937 +{
71938 +#ifdef CONFIG_GRKERNSEC_BRUTE
71939 + struct user_struct *user = current->cred->user;
71940 + if (unlikely(user->suid_banned)) {
71941 + if (suid_ban_expired(user))
71942 + return 0;
71943 + /* disallow execution of suid binaries only */
71944 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
71945 + return -EPERM;
71946 + }
71947 +#endif
71948 + return 0;
71949 +}
71950 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
71951 new file mode 100644
71952 index 0000000..4030d57
71953 --- /dev/null
71954 +++ b/grsecurity/grsec_sock.c
71955 @@ -0,0 +1,244 @@
71956 +#include <linux/kernel.h>
71957 +#include <linux/module.h>
71958 +#include <linux/sched.h>
71959 +#include <linux/file.h>
71960 +#include <linux/net.h>
71961 +#include <linux/in.h>
71962 +#include <linux/ip.h>
71963 +#include <net/sock.h>
71964 +#include <net/inet_sock.h>
71965 +#include <linux/grsecurity.h>
71966 +#include <linux/grinternal.h>
71967 +#include <linux/gracl.h>
71968 +
71969 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
71970 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
71971 +
71972 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
71973 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
71974 +
71975 +#ifdef CONFIG_UNIX_MODULE
71976 +EXPORT_SYMBOL(gr_acl_handle_unix);
71977 +EXPORT_SYMBOL(gr_acl_handle_mknod);
71978 +EXPORT_SYMBOL(gr_handle_chroot_unix);
71979 +EXPORT_SYMBOL(gr_handle_create);
71980 +#endif
71981 +
71982 +#ifdef CONFIG_GRKERNSEC
71983 +#define gr_conn_table_size 32749
71984 +struct conn_table_entry {
71985 + struct conn_table_entry *next;
71986 + struct signal_struct *sig;
71987 +};
71988 +
71989 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
71990 +DEFINE_SPINLOCK(gr_conn_table_lock);
71991 +
71992 +extern const char * gr_socktype_to_name(unsigned char type);
71993 +extern const char * gr_proto_to_name(unsigned char proto);
71994 +extern const char * gr_sockfamily_to_name(unsigned char family);
71995 +
71996 +static __inline__ int
71997 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
71998 +{
71999 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
72000 +}
72001 +
72002 +static __inline__ int
72003 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
72004 + __u16 sport, __u16 dport)
72005 +{
72006 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
72007 + sig->gr_sport == sport && sig->gr_dport == dport))
72008 + return 1;
72009 + else
72010 + return 0;
72011 +}
72012 +
72013 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
72014 +{
72015 + struct conn_table_entry **match;
72016 + unsigned int index;
72017 +
72018 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72019 + sig->gr_sport, sig->gr_dport,
72020 + gr_conn_table_size);
72021 +
72022 + newent->sig = sig;
72023 +
72024 + match = &gr_conn_table[index];
72025 + newent->next = *match;
72026 + *match = newent;
72027 +
72028 + return;
72029 +}
72030 +
72031 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
72032 +{
72033 + struct conn_table_entry *match, *last = NULL;
72034 + unsigned int index;
72035 +
72036 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72037 + sig->gr_sport, sig->gr_dport,
72038 + gr_conn_table_size);
72039 +
72040 + match = gr_conn_table[index];
72041 + while (match && !conn_match(match->sig,
72042 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
72043 + sig->gr_dport)) {
72044 + last = match;
72045 + match = match->next;
72046 + }
72047 +
72048 + if (match) {
72049 + if (last)
72050 + last->next = match->next;
72051 + else
72052 + gr_conn_table[index] = NULL;
72053 + kfree(match);
72054 + }
72055 +
72056 + return;
72057 +}
72058 +
72059 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
72060 + __u16 sport, __u16 dport)
72061 +{
72062 + struct conn_table_entry *match;
72063 + unsigned int index;
72064 +
72065 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
72066 +
72067 + match = gr_conn_table[index];
72068 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
72069 + match = match->next;
72070 +
72071 + if (match)
72072 + return match->sig;
72073 + else
72074 + return NULL;
72075 +}
72076 +
72077 +#endif
72078 +
72079 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
72080 +{
72081 +#ifdef CONFIG_GRKERNSEC
72082 + struct signal_struct *sig = task->signal;
72083 + struct conn_table_entry *newent;
72084 +
72085 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
72086 + if (newent == NULL)
72087 + return;
72088 + /* no bh lock needed since we are called with bh disabled */
72089 + spin_lock(&gr_conn_table_lock);
72090 + gr_del_task_from_ip_table_nolock(sig);
72091 + sig->gr_saddr = inet->inet_rcv_saddr;
72092 + sig->gr_daddr = inet->inet_daddr;
72093 + sig->gr_sport = inet->inet_sport;
72094 + sig->gr_dport = inet->inet_dport;
72095 + gr_add_to_task_ip_table_nolock(sig, newent);
72096 + spin_unlock(&gr_conn_table_lock);
72097 +#endif
72098 + return;
72099 +}
72100 +
72101 +void gr_del_task_from_ip_table(struct task_struct *task)
72102 +{
72103 +#ifdef CONFIG_GRKERNSEC
72104 + spin_lock_bh(&gr_conn_table_lock);
72105 + gr_del_task_from_ip_table_nolock(task->signal);
72106 + spin_unlock_bh(&gr_conn_table_lock);
72107 +#endif
72108 + return;
72109 +}
72110 +
72111 +void
72112 +gr_attach_curr_ip(const struct sock *sk)
72113 +{
72114 +#ifdef CONFIG_GRKERNSEC
72115 + struct signal_struct *p, *set;
72116 + const struct inet_sock *inet = inet_sk(sk);
72117 +
72118 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
72119 + return;
72120 +
72121 + set = current->signal;
72122 +
72123 + spin_lock_bh(&gr_conn_table_lock);
72124 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
72125 + inet->inet_dport, inet->inet_sport);
72126 + if (unlikely(p != NULL)) {
72127 + set->curr_ip = p->curr_ip;
72128 + set->used_accept = 1;
72129 + gr_del_task_from_ip_table_nolock(p);
72130 + spin_unlock_bh(&gr_conn_table_lock);
72131 + return;
72132 + }
72133 + spin_unlock_bh(&gr_conn_table_lock);
72134 +
72135 + set->curr_ip = inet->inet_daddr;
72136 + set->used_accept = 1;
72137 +#endif
72138 + return;
72139 +}
72140 +
72141 +int
72142 +gr_handle_sock_all(const int family, const int type, const int protocol)
72143 +{
72144 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72145 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
72146 + (family != AF_UNIX)) {
72147 + if (family == AF_INET)
72148 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
72149 + else
72150 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
72151 + return -EACCES;
72152 + }
72153 +#endif
72154 + return 0;
72155 +}
72156 +
72157 +int
72158 +gr_handle_sock_server(const struct sockaddr *sck)
72159 +{
72160 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72161 + if (grsec_enable_socket_server &&
72162 + in_group_p(grsec_socket_server_gid) &&
72163 + sck && (sck->sa_family != AF_UNIX) &&
72164 + (sck->sa_family != AF_LOCAL)) {
72165 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72166 + return -EACCES;
72167 + }
72168 +#endif
72169 + return 0;
72170 +}
72171 +
72172 +int
72173 +gr_handle_sock_server_other(const struct sock *sck)
72174 +{
72175 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72176 + if (grsec_enable_socket_server &&
72177 + in_group_p(grsec_socket_server_gid) &&
72178 + sck && (sck->sk_family != AF_UNIX) &&
72179 + (sck->sk_family != AF_LOCAL)) {
72180 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72181 + return -EACCES;
72182 + }
72183 +#endif
72184 + return 0;
72185 +}
72186 +
72187 +int
72188 +gr_handle_sock_client(const struct sockaddr *sck)
72189 +{
72190 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72191 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
72192 + sck && (sck->sa_family != AF_UNIX) &&
72193 + (sck->sa_family != AF_LOCAL)) {
72194 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
72195 + return -EACCES;
72196 + }
72197 +#endif
72198 + return 0;
72199 +}
72200 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
72201 new file mode 100644
72202 index 0000000..a147ae7
72203 --- /dev/null
72204 +++ b/grsecurity/grsec_sysctl.c
72205 @@ -0,0 +1,470 @@
72206 +#include <linux/kernel.h>
72207 +#include <linux/sched.h>
72208 +#include <linux/sysctl.h>
72209 +#include <linux/grsecurity.h>
72210 +#include <linux/grinternal.h>
72211 +
72212 +int
72213 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
72214 +{
72215 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72216 + if (dirname == NULL || name == NULL)
72217 + return 0;
72218 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
72219 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
72220 + return -EACCES;
72221 + }
72222 +#endif
72223 + return 0;
72224 +}
72225 +
72226 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
72227 +static int __maybe_unused __read_only one = 1;
72228 +#endif
72229 +
72230 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
72231 + defined(CONFIG_GRKERNSEC_DENYUSB)
72232 +struct ctl_table grsecurity_table[] = {
72233 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72234 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
72235 +#ifdef CONFIG_GRKERNSEC_IO
72236 + {
72237 + .procname = "disable_priv_io",
72238 + .data = &grsec_disable_privio,
72239 + .maxlen = sizeof(int),
72240 + .mode = 0600,
72241 + .proc_handler = &proc_dointvec,
72242 + },
72243 +#endif
72244 +#endif
72245 +#ifdef CONFIG_GRKERNSEC_LINK
72246 + {
72247 + .procname = "linking_restrictions",
72248 + .data = &grsec_enable_link,
72249 + .maxlen = sizeof(int),
72250 + .mode = 0600,
72251 + .proc_handler = &proc_dointvec,
72252 + },
72253 +#endif
72254 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
72255 + {
72256 + .procname = "enforce_symlinksifowner",
72257 + .data = &grsec_enable_symlinkown,
72258 + .maxlen = sizeof(int),
72259 + .mode = 0600,
72260 + .proc_handler = &proc_dointvec,
72261 + },
72262 + {
72263 + .procname = "symlinkown_gid",
72264 + .data = &grsec_symlinkown_gid,
72265 + .maxlen = sizeof(int),
72266 + .mode = 0600,
72267 + .proc_handler = &proc_dointvec,
72268 + },
72269 +#endif
72270 +#ifdef CONFIG_GRKERNSEC_BRUTE
72271 + {
72272 + .procname = "deter_bruteforce",
72273 + .data = &grsec_enable_brute,
72274 + .maxlen = sizeof(int),
72275 + .mode = 0600,
72276 + .proc_handler = &proc_dointvec,
72277 + },
72278 +#endif
72279 +#ifdef CONFIG_GRKERNSEC_FIFO
72280 + {
72281 + .procname = "fifo_restrictions",
72282 + .data = &grsec_enable_fifo,
72283 + .maxlen = sizeof(int),
72284 + .mode = 0600,
72285 + .proc_handler = &proc_dointvec,
72286 + },
72287 +#endif
72288 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72289 + {
72290 + .procname = "ptrace_readexec",
72291 + .data = &grsec_enable_ptrace_readexec,
72292 + .maxlen = sizeof(int),
72293 + .mode = 0600,
72294 + .proc_handler = &proc_dointvec,
72295 + },
72296 +#endif
72297 +#ifdef CONFIG_GRKERNSEC_SETXID
72298 + {
72299 + .procname = "consistent_setxid",
72300 + .data = &grsec_enable_setxid,
72301 + .maxlen = sizeof(int),
72302 + .mode = 0600,
72303 + .proc_handler = &proc_dointvec,
72304 + },
72305 +#endif
72306 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
72307 + {
72308 + .procname = "ip_blackhole",
72309 + .data = &grsec_enable_blackhole,
72310 + .maxlen = sizeof(int),
72311 + .mode = 0600,
72312 + .proc_handler = &proc_dointvec,
72313 + },
72314 + {
72315 + .procname = "lastack_retries",
72316 + .data = &grsec_lastack_retries,
72317 + .maxlen = sizeof(int),
72318 + .mode = 0600,
72319 + .proc_handler = &proc_dointvec,
72320 + },
72321 +#endif
72322 +#ifdef CONFIG_GRKERNSEC_EXECLOG
72323 + {
72324 + .procname = "exec_logging",
72325 + .data = &grsec_enable_execlog,
72326 + .maxlen = sizeof(int),
72327 + .mode = 0600,
72328 + .proc_handler = &proc_dointvec,
72329 + },
72330 +#endif
72331 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72332 + {
72333 + .procname = "rwxmap_logging",
72334 + .data = &grsec_enable_log_rwxmaps,
72335 + .maxlen = sizeof(int),
72336 + .mode = 0600,
72337 + .proc_handler = &proc_dointvec,
72338 + },
72339 +#endif
72340 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72341 + {
72342 + .procname = "signal_logging",
72343 + .data = &grsec_enable_signal,
72344 + .maxlen = sizeof(int),
72345 + .mode = 0600,
72346 + .proc_handler = &proc_dointvec,
72347 + },
72348 +#endif
72349 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
72350 + {
72351 + .procname = "forkfail_logging",
72352 + .data = &grsec_enable_forkfail,
72353 + .maxlen = sizeof(int),
72354 + .mode = 0600,
72355 + .proc_handler = &proc_dointvec,
72356 + },
72357 +#endif
72358 +#ifdef CONFIG_GRKERNSEC_TIME
72359 + {
72360 + .procname = "timechange_logging",
72361 + .data = &grsec_enable_time,
72362 + .maxlen = sizeof(int),
72363 + .mode = 0600,
72364 + .proc_handler = &proc_dointvec,
72365 + },
72366 +#endif
72367 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
72368 + {
72369 + .procname = "chroot_deny_shmat",
72370 + .data = &grsec_enable_chroot_shmat,
72371 + .maxlen = sizeof(int),
72372 + .mode = 0600,
72373 + .proc_handler = &proc_dointvec,
72374 + },
72375 +#endif
72376 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
72377 + {
72378 + .procname = "chroot_deny_unix",
72379 + .data = &grsec_enable_chroot_unix,
72380 + .maxlen = sizeof(int),
72381 + .mode = 0600,
72382 + .proc_handler = &proc_dointvec,
72383 + },
72384 +#endif
72385 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
72386 + {
72387 + .procname = "chroot_deny_mount",
72388 + .data = &grsec_enable_chroot_mount,
72389 + .maxlen = sizeof(int),
72390 + .mode = 0600,
72391 + .proc_handler = &proc_dointvec,
72392 + },
72393 +#endif
72394 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
72395 + {
72396 + .procname = "chroot_deny_fchdir",
72397 + .data = &grsec_enable_chroot_fchdir,
72398 + .maxlen = sizeof(int),
72399 + .mode = 0600,
72400 + .proc_handler = &proc_dointvec,
72401 + },
72402 +#endif
72403 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
72404 + {
72405 + .procname = "chroot_deny_chroot",
72406 + .data = &grsec_enable_chroot_double,
72407 + .maxlen = sizeof(int),
72408 + .mode = 0600,
72409 + .proc_handler = &proc_dointvec,
72410 + },
72411 +#endif
72412 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
72413 + {
72414 + .procname = "chroot_deny_pivot",
72415 + .data = &grsec_enable_chroot_pivot,
72416 + .maxlen = sizeof(int),
72417 + .mode = 0600,
72418 + .proc_handler = &proc_dointvec,
72419 + },
72420 +#endif
72421 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
72422 + {
72423 + .procname = "chroot_enforce_chdir",
72424 + .data = &grsec_enable_chroot_chdir,
72425 + .maxlen = sizeof(int),
72426 + .mode = 0600,
72427 + .proc_handler = &proc_dointvec,
72428 + },
72429 +#endif
72430 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
72431 + {
72432 + .procname = "chroot_deny_chmod",
72433 + .data = &grsec_enable_chroot_chmod,
72434 + .maxlen = sizeof(int),
72435 + .mode = 0600,
72436 + .proc_handler = &proc_dointvec,
72437 + },
72438 +#endif
72439 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
72440 + {
72441 + .procname = "chroot_deny_mknod",
72442 + .data = &grsec_enable_chroot_mknod,
72443 + .maxlen = sizeof(int),
72444 + .mode = 0600,
72445 + .proc_handler = &proc_dointvec,
72446 + },
72447 +#endif
72448 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
72449 + {
72450 + .procname = "chroot_restrict_nice",
72451 + .data = &grsec_enable_chroot_nice,
72452 + .maxlen = sizeof(int),
72453 + .mode = 0600,
72454 + .proc_handler = &proc_dointvec,
72455 + },
72456 +#endif
72457 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
72458 + {
72459 + .procname = "chroot_execlog",
72460 + .data = &grsec_enable_chroot_execlog,
72461 + .maxlen = sizeof(int),
72462 + .mode = 0600,
72463 + .proc_handler = &proc_dointvec,
72464 + },
72465 +#endif
72466 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
72467 + {
72468 + .procname = "chroot_caps",
72469 + .data = &grsec_enable_chroot_caps,
72470 + .maxlen = sizeof(int),
72471 + .mode = 0600,
72472 + .proc_handler = &proc_dointvec,
72473 + },
72474 +#endif
72475 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
72476 + {
72477 + .procname = "chroot_deny_sysctl",
72478 + .data = &grsec_enable_chroot_sysctl,
72479 + .maxlen = sizeof(int),
72480 + .mode = 0600,
72481 + .proc_handler = &proc_dointvec,
72482 + },
72483 +#endif
72484 +#ifdef CONFIG_GRKERNSEC_TPE
72485 + {
72486 + .procname = "tpe",
72487 + .data = &grsec_enable_tpe,
72488 + .maxlen = sizeof(int),
72489 + .mode = 0600,
72490 + .proc_handler = &proc_dointvec,
72491 + },
72492 + {
72493 + .procname = "tpe_gid",
72494 + .data = &grsec_tpe_gid,
72495 + .maxlen = sizeof(int),
72496 + .mode = 0600,
72497 + .proc_handler = &proc_dointvec,
72498 + },
72499 +#endif
72500 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72501 + {
72502 + .procname = "tpe_invert",
72503 + .data = &grsec_enable_tpe_invert,
72504 + .maxlen = sizeof(int),
72505 + .mode = 0600,
72506 + .proc_handler = &proc_dointvec,
72507 + },
72508 +#endif
72509 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72510 + {
72511 + .procname = "tpe_restrict_all",
72512 + .data = &grsec_enable_tpe_all,
72513 + .maxlen = sizeof(int),
72514 + .mode = 0600,
72515 + .proc_handler = &proc_dointvec,
72516 + },
72517 +#endif
72518 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72519 + {
72520 + .procname = "socket_all",
72521 + .data = &grsec_enable_socket_all,
72522 + .maxlen = sizeof(int),
72523 + .mode = 0600,
72524 + .proc_handler = &proc_dointvec,
72525 + },
72526 + {
72527 + .procname = "socket_all_gid",
72528 + .data = &grsec_socket_all_gid,
72529 + .maxlen = sizeof(int),
72530 + .mode = 0600,
72531 + .proc_handler = &proc_dointvec,
72532 + },
72533 +#endif
72534 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72535 + {
72536 + .procname = "socket_client",
72537 + .data = &grsec_enable_socket_client,
72538 + .maxlen = sizeof(int),
72539 + .mode = 0600,
72540 + .proc_handler = &proc_dointvec,
72541 + },
72542 + {
72543 + .procname = "socket_client_gid",
72544 + .data = &grsec_socket_client_gid,
72545 + .maxlen = sizeof(int),
72546 + .mode = 0600,
72547 + .proc_handler = &proc_dointvec,
72548 + },
72549 +#endif
72550 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72551 + {
72552 + .procname = "socket_server",
72553 + .data = &grsec_enable_socket_server,
72554 + .maxlen = sizeof(int),
72555 + .mode = 0600,
72556 + .proc_handler = &proc_dointvec,
72557 + },
72558 + {
72559 + .procname = "socket_server_gid",
72560 + .data = &grsec_socket_server_gid,
72561 + .maxlen = sizeof(int),
72562 + .mode = 0600,
72563 + .proc_handler = &proc_dointvec,
72564 + },
72565 +#endif
72566 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72567 + {
72568 + .procname = "audit_group",
72569 + .data = &grsec_enable_group,
72570 + .maxlen = sizeof(int),
72571 + .mode = 0600,
72572 + .proc_handler = &proc_dointvec,
72573 + },
72574 + {
72575 + .procname = "audit_gid",
72576 + .data = &grsec_audit_gid,
72577 + .maxlen = sizeof(int),
72578 + .mode = 0600,
72579 + .proc_handler = &proc_dointvec,
72580 + },
72581 +#endif
72582 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72583 + {
72584 + .procname = "audit_chdir",
72585 + .data = &grsec_enable_chdir,
72586 + .maxlen = sizeof(int),
72587 + .mode = 0600,
72588 + .proc_handler = &proc_dointvec,
72589 + },
72590 +#endif
72591 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72592 + {
72593 + .procname = "audit_mount",
72594 + .data = &grsec_enable_mount,
72595 + .maxlen = sizeof(int),
72596 + .mode = 0600,
72597 + .proc_handler = &proc_dointvec,
72598 + },
72599 +#endif
72600 +#ifdef CONFIG_GRKERNSEC_DMESG
72601 + {
72602 + .procname = "dmesg",
72603 + .data = &grsec_enable_dmesg,
72604 + .maxlen = sizeof(int),
72605 + .mode = 0600,
72606 + .proc_handler = &proc_dointvec,
72607 + },
72608 +#endif
72609 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72610 + {
72611 + .procname = "chroot_findtask",
72612 + .data = &grsec_enable_chroot_findtask,
72613 + .maxlen = sizeof(int),
72614 + .mode = 0600,
72615 + .proc_handler = &proc_dointvec,
72616 + },
72617 +#endif
72618 +#ifdef CONFIG_GRKERNSEC_RESLOG
72619 + {
72620 + .procname = "resource_logging",
72621 + .data = &grsec_resource_logging,
72622 + .maxlen = sizeof(int),
72623 + .mode = 0600,
72624 + .proc_handler = &proc_dointvec,
72625 + },
72626 +#endif
72627 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72628 + {
72629 + .procname = "audit_ptrace",
72630 + .data = &grsec_enable_audit_ptrace,
72631 + .maxlen = sizeof(int),
72632 + .mode = 0600,
72633 + .proc_handler = &proc_dointvec,
72634 + },
72635 +#endif
72636 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72637 + {
72638 + .procname = "harden_ptrace",
72639 + .data = &grsec_enable_harden_ptrace,
72640 + .maxlen = sizeof(int),
72641 + .mode = 0600,
72642 + .proc_handler = &proc_dointvec,
72643 + },
72644 +#endif
72645 + {
72646 + .procname = "grsec_lock",
72647 + .data = &grsec_lock,
72648 + .maxlen = sizeof(int),
72649 + .mode = 0600,
72650 + .proc_handler = &proc_dointvec,
72651 + },
72652 +#endif
72653 +#ifdef CONFIG_GRKERNSEC_ROFS
72654 + {
72655 + .procname = "romount_protect",
72656 + .data = &grsec_enable_rofs,
72657 + .maxlen = sizeof(int),
72658 + .mode = 0600,
72659 + .proc_handler = &proc_dointvec_minmax,
72660 + .extra1 = &one,
72661 + .extra2 = &one,
72662 + },
72663 +#endif
72664 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
72665 + {
72666 + .procname = "deny_new_usb",
72667 + .data = &grsec_deny_new_usb,
72668 + .maxlen = sizeof(int),
72669 + .mode = 0600,
72670 + .proc_handler = &proc_dointvec,
72671 + },
72672 +#endif
72673 + { }
72674 +};
72675 +#endif
72676 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72677 new file mode 100644
72678 index 0000000..0dc13c3
72679 --- /dev/null
72680 +++ b/grsecurity/grsec_time.c
72681 @@ -0,0 +1,16 @@
72682 +#include <linux/kernel.h>
72683 +#include <linux/sched.h>
72684 +#include <linux/grinternal.h>
72685 +#include <linux/module.h>
72686 +
72687 +void
72688 +gr_log_timechange(void)
72689 +{
72690 +#ifdef CONFIG_GRKERNSEC_TIME
72691 + if (grsec_enable_time)
72692 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72693 +#endif
72694 + return;
72695 +}
72696 +
72697 +EXPORT_SYMBOL(gr_log_timechange);
72698 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72699 new file mode 100644
72700 index 0000000..ee57dcf
72701 --- /dev/null
72702 +++ b/grsecurity/grsec_tpe.c
72703 @@ -0,0 +1,73 @@
72704 +#include <linux/kernel.h>
72705 +#include <linux/sched.h>
72706 +#include <linux/file.h>
72707 +#include <linux/fs.h>
72708 +#include <linux/grinternal.h>
72709 +
72710 +extern int gr_acl_tpe_check(void);
72711 +
72712 +int
72713 +gr_tpe_allow(const struct file *file)
72714 +{
72715 +#ifdef CONFIG_GRKERNSEC
72716 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72717 + const struct cred *cred = current_cred();
72718 + char *msg = NULL;
72719 + char *msg2 = NULL;
72720 +
72721 + // never restrict root
72722 + if (gr_is_global_root(cred->uid))
72723 + return 1;
72724 +
72725 + if (grsec_enable_tpe) {
72726 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72727 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72728 + msg = "not being in trusted group";
72729 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72730 + msg = "being in untrusted group";
72731 +#else
72732 + if (in_group_p(grsec_tpe_gid))
72733 + msg = "being in untrusted group";
72734 +#endif
72735 + }
72736 + if (!msg && gr_acl_tpe_check())
72737 + msg = "being in untrusted role";
72738 +
72739 + // not in any affected group/role
72740 + if (!msg)
72741 + goto next_check;
72742 +
72743 + if (gr_is_global_nonroot(inode->i_uid))
72744 + msg2 = "file in non-root-owned directory";
72745 + else if (inode->i_mode & S_IWOTH)
72746 + msg2 = "file in world-writable directory";
72747 + else if (inode->i_mode & S_IWGRP)
72748 + msg2 = "file in group-writable directory";
72749 +
72750 + if (msg && msg2) {
72751 + char fullmsg[70] = {0};
72752 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72753 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72754 + return 0;
72755 + }
72756 + msg = NULL;
72757 +next_check:
72758 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72759 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72760 + return 1;
72761 +
72762 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72763 + msg = "directory not owned by user";
72764 + else if (inode->i_mode & S_IWOTH)
72765 + msg = "file in world-writable directory";
72766 + else if (inode->i_mode & S_IWGRP)
72767 + msg = "file in group-writable directory";
72768 +
72769 + if (msg) {
72770 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72771 + return 0;
72772 + }
72773 +#endif
72774 +#endif
72775 + return 1;
72776 +}
72777 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72778 new file mode 100644
72779 index 0000000..ae02d8e
72780 --- /dev/null
72781 +++ b/grsecurity/grsec_usb.c
72782 @@ -0,0 +1,15 @@
72783 +#include <linux/kernel.h>
72784 +#include <linux/grinternal.h>
72785 +#include <linux/module.h>
72786 +
72787 +int gr_handle_new_usb(void)
72788 +{
72789 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72790 + if (grsec_deny_new_usb) {
72791 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72792 + return 1;
72793 + }
72794 +#endif
72795 + return 0;
72796 +}
72797 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72798 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72799 new file mode 100644
72800 index 0000000..9f7b1ac
72801 --- /dev/null
72802 +++ b/grsecurity/grsum.c
72803 @@ -0,0 +1,61 @@
72804 +#include <linux/err.h>
72805 +#include <linux/kernel.h>
72806 +#include <linux/sched.h>
72807 +#include <linux/mm.h>
72808 +#include <linux/scatterlist.h>
72809 +#include <linux/crypto.h>
72810 +#include <linux/gracl.h>
72811 +
72812 +
72813 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
72814 +#error "crypto and sha256 must be built into the kernel"
72815 +#endif
72816 +
72817 +int
72818 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
72819 +{
72820 + char *p;
72821 + struct crypto_hash *tfm;
72822 + struct hash_desc desc;
72823 + struct scatterlist sg;
72824 + unsigned char temp_sum[GR_SHA_LEN];
72825 + volatile int retval = 0;
72826 + volatile int dummy = 0;
72827 + unsigned int i;
72828 +
72829 + sg_init_table(&sg, 1);
72830 +
72831 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
72832 + if (IS_ERR(tfm)) {
72833 + /* should never happen, since sha256 should be built in */
72834 + return 1;
72835 + }
72836 +
72837 + desc.tfm = tfm;
72838 + desc.flags = 0;
72839 +
72840 + crypto_hash_init(&desc);
72841 +
72842 + p = salt;
72843 + sg_set_buf(&sg, p, GR_SALT_LEN);
72844 + crypto_hash_update(&desc, &sg, sg.length);
72845 +
72846 + p = entry->pw;
72847 + sg_set_buf(&sg, p, strlen(p));
72848 +
72849 + crypto_hash_update(&desc, &sg, sg.length);
72850 +
72851 + crypto_hash_final(&desc, temp_sum);
72852 +
72853 + memset(entry->pw, 0, GR_PW_LEN);
72854 +
72855 + for (i = 0; i < GR_SHA_LEN; i++)
72856 + if (sum[i] != temp_sum[i])
72857 + retval = 1;
72858 + else
72859 + dummy = 1; // waste a cycle
72860 +
72861 + crypto_free_hash(tfm);
72862 +
72863 + return retval;
72864 +}
72865 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
72866 index 77ff547..181834f 100644
72867 --- a/include/asm-generic/4level-fixup.h
72868 +++ b/include/asm-generic/4level-fixup.h
72869 @@ -13,8 +13,10 @@
72870 #define pmd_alloc(mm, pud, address) \
72871 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
72872 NULL: pmd_offset(pud, address))
72873 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
72874
72875 #define pud_alloc(mm, pgd, address) (pgd)
72876 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
72877 #define pud_offset(pgd, start) (pgd)
72878 #define pud_none(pud) 0
72879 #define pud_bad(pud) 0
72880 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
72881 index b7babf0..04ad282 100644
72882 --- a/include/asm-generic/atomic-long.h
72883 +++ b/include/asm-generic/atomic-long.h
72884 @@ -22,6 +22,12 @@
72885
72886 typedef atomic64_t atomic_long_t;
72887
72888 +#ifdef CONFIG_PAX_REFCOUNT
72889 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
72890 +#else
72891 +typedef atomic64_t atomic_long_unchecked_t;
72892 +#endif
72893 +
72894 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
72895
72896 static inline long atomic_long_read(atomic_long_t *l)
72897 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72898 return (long)atomic64_read(v);
72899 }
72900
72901 +#ifdef CONFIG_PAX_REFCOUNT
72902 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72903 +{
72904 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72905 +
72906 + return (long)atomic64_read_unchecked(v);
72907 +}
72908 +#endif
72909 +
72910 static inline void atomic_long_set(atomic_long_t *l, long i)
72911 {
72912 atomic64_t *v = (atomic64_t *)l;
72913 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72914 atomic64_set(v, i);
72915 }
72916
72917 +#ifdef CONFIG_PAX_REFCOUNT
72918 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72919 +{
72920 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72921 +
72922 + atomic64_set_unchecked(v, i);
72923 +}
72924 +#endif
72925 +
72926 static inline void atomic_long_inc(atomic_long_t *l)
72927 {
72928 atomic64_t *v = (atomic64_t *)l;
72929 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72930 atomic64_inc(v);
72931 }
72932
72933 +#ifdef CONFIG_PAX_REFCOUNT
72934 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72935 +{
72936 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72937 +
72938 + atomic64_inc_unchecked(v);
72939 +}
72940 +#endif
72941 +
72942 static inline void atomic_long_dec(atomic_long_t *l)
72943 {
72944 atomic64_t *v = (atomic64_t *)l;
72945 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72946 atomic64_dec(v);
72947 }
72948
72949 +#ifdef CONFIG_PAX_REFCOUNT
72950 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72951 +{
72952 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72953 +
72954 + atomic64_dec_unchecked(v);
72955 +}
72956 +#endif
72957 +
72958 static inline void atomic_long_add(long i, atomic_long_t *l)
72959 {
72960 atomic64_t *v = (atomic64_t *)l;
72961 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72962 atomic64_add(i, v);
72963 }
72964
72965 +#ifdef CONFIG_PAX_REFCOUNT
72966 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72967 +{
72968 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72969 +
72970 + atomic64_add_unchecked(i, v);
72971 +}
72972 +#endif
72973 +
72974 static inline void atomic_long_sub(long i, atomic_long_t *l)
72975 {
72976 atomic64_t *v = (atomic64_t *)l;
72977 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72978 atomic64_sub(i, v);
72979 }
72980
72981 +#ifdef CONFIG_PAX_REFCOUNT
72982 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72983 +{
72984 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72985 +
72986 + atomic64_sub_unchecked(i, v);
72987 +}
72988 +#endif
72989 +
72990 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72991 {
72992 atomic64_t *v = (atomic64_t *)l;
72993 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72994 return (long)atomic64_add_return(i, v);
72995 }
72996
72997 +#ifdef CONFIG_PAX_REFCOUNT
72998 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72999 +{
73000 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73001 +
73002 + return (long)atomic64_add_return_unchecked(i, v);
73003 +}
73004 +#endif
73005 +
73006 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73007 {
73008 atomic64_t *v = (atomic64_t *)l;
73009 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73010 return (long)atomic64_inc_return(v);
73011 }
73012
73013 +#ifdef CONFIG_PAX_REFCOUNT
73014 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73015 +{
73016 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73017 +
73018 + return (long)atomic64_inc_return_unchecked(v);
73019 +}
73020 +#endif
73021 +
73022 static inline long atomic_long_dec_return(atomic_long_t *l)
73023 {
73024 atomic64_t *v = (atomic64_t *)l;
73025 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73026
73027 typedef atomic_t atomic_long_t;
73028
73029 +#ifdef CONFIG_PAX_REFCOUNT
73030 +typedef atomic_unchecked_t atomic_long_unchecked_t;
73031 +#else
73032 +typedef atomic_t atomic_long_unchecked_t;
73033 +#endif
73034 +
73035 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
73036 static inline long atomic_long_read(atomic_long_t *l)
73037 {
73038 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73039 return (long)atomic_read(v);
73040 }
73041
73042 +#ifdef CONFIG_PAX_REFCOUNT
73043 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73044 +{
73045 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73046 +
73047 + return (long)atomic_read_unchecked(v);
73048 +}
73049 +#endif
73050 +
73051 static inline void atomic_long_set(atomic_long_t *l, long i)
73052 {
73053 atomic_t *v = (atomic_t *)l;
73054 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73055 atomic_set(v, i);
73056 }
73057
73058 +#ifdef CONFIG_PAX_REFCOUNT
73059 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73060 +{
73061 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73062 +
73063 + atomic_set_unchecked(v, i);
73064 +}
73065 +#endif
73066 +
73067 static inline void atomic_long_inc(atomic_long_t *l)
73068 {
73069 atomic_t *v = (atomic_t *)l;
73070 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73071 atomic_inc(v);
73072 }
73073
73074 +#ifdef CONFIG_PAX_REFCOUNT
73075 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73076 +{
73077 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73078 +
73079 + atomic_inc_unchecked(v);
73080 +}
73081 +#endif
73082 +
73083 static inline void atomic_long_dec(atomic_long_t *l)
73084 {
73085 atomic_t *v = (atomic_t *)l;
73086 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73087 atomic_dec(v);
73088 }
73089
73090 +#ifdef CONFIG_PAX_REFCOUNT
73091 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73092 +{
73093 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73094 +
73095 + atomic_dec_unchecked(v);
73096 +}
73097 +#endif
73098 +
73099 static inline void atomic_long_add(long i, atomic_long_t *l)
73100 {
73101 atomic_t *v = (atomic_t *)l;
73102 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73103 atomic_add(i, v);
73104 }
73105
73106 +#ifdef CONFIG_PAX_REFCOUNT
73107 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73108 +{
73109 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73110 +
73111 + atomic_add_unchecked(i, v);
73112 +}
73113 +#endif
73114 +
73115 static inline void atomic_long_sub(long i, atomic_long_t *l)
73116 {
73117 atomic_t *v = (atomic_t *)l;
73118 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73119 atomic_sub(i, v);
73120 }
73121
73122 +#ifdef CONFIG_PAX_REFCOUNT
73123 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73124 +{
73125 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73126 +
73127 + atomic_sub_unchecked(i, v);
73128 +}
73129 +#endif
73130 +
73131 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73132 {
73133 atomic_t *v = (atomic_t *)l;
73134 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
73135 return (long)atomic_add_return(i, v);
73136 }
73137
73138 +#ifdef CONFIG_PAX_REFCOUNT
73139 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73140 +{
73141 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73142 +
73143 + return (long)atomic_add_return_unchecked(i, v);
73144 +}
73145 +
73146 +#endif
73147 +
73148 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73149 {
73150 atomic_t *v = (atomic_t *)l;
73151 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73152 return (long)atomic_inc_return(v);
73153 }
73154
73155 +#ifdef CONFIG_PAX_REFCOUNT
73156 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73157 +{
73158 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73159 +
73160 + return (long)atomic_inc_return_unchecked(v);
73161 +}
73162 +#endif
73163 +
73164 static inline long atomic_long_dec_return(atomic_long_t *l)
73165 {
73166 atomic_t *v = (atomic_t *)l;
73167 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73168
73169 #endif /* BITS_PER_LONG == 64 */
73170
73171 +#ifdef CONFIG_PAX_REFCOUNT
73172 +static inline void pax_refcount_needs_these_functions(void)
73173 +{
73174 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
73175 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
73176 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
73177 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
73178 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
73179 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
73180 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
73181 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
73182 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
73183 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
73184 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
73185 +#ifdef CONFIG_X86
73186 + atomic_clear_mask_unchecked(0, NULL);
73187 + atomic_set_mask_unchecked(0, NULL);
73188 +#endif
73189 +
73190 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
73191 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
73192 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
73193 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
73194 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
73195 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
73196 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
73197 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
73198 +}
73199 +#else
73200 +#define atomic_read_unchecked(v) atomic_read(v)
73201 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
73202 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
73203 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
73204 +#define atomic_inc_unchecked(v) atomic_inc(v)
73205 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
73206 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
73207 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
73208 +#define atomic_dec_unchecked(v) atomic_dec(v)
73209 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
73210 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
73211 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
73212 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
73213 +
73214 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
73215 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
73216 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
73217 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
73218 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
73219 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
73220 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
73221 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
73222 +#endif
73223 +
73224 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
73225 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
73226 index 33bd2de..f31bff97 100644
73227 --- a/include/asm-generic/atomic.h
73228 +++ b/include/asm-generic/atomic.h
73229 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
73230 * Atomically clears the bits set in @mask from @v
73231 */
73232 #ifndef atomic_clear_mask
73233 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
73234 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
73235 {
73236 unsigned long flags;
73237
73238 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
73239 index b18ce4f..2ee2843 100644
73240 --- a/include/asm-generic/atomic64.h
73241 +++ b/include/asm-generic/atomic64.h
73242 @@ -16,6 +16,8 @@ typedef struct {
73243 long long counter;
73244 } atomic64_t;
73245
73246 +typedef atomic64_t atomic64_unchecked_t;
73247 +
73248 #define ATOMIC64_INIT(i) { (i) }
73249
73250 extern long long atomic64_read(const atomic64_t *v);
73251 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
73252 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
73253 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
73254
73255 +#define atomic64_read_unchecked(v) atomic64_read(v)
73256 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
73257 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
73258 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
73259 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
73260 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
73261 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
73262 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
73263 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
73264 +
73265 #endif /* _ASM_GENERIC_ATOMIC64_H */
73266 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
73267 index 1bfcfe5..e04c5c9 100644
73268 --- a/include/asm-generic/cache.h
73269 +++ b/include/asm-generic/cache.h
73270 @@ -6,7 +6,7 @@
73271 * cache lines need to provide their own cache.h.
73272 */
73273
73274 -#define L1_CACHE_SHIFT 5
73275 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
73276 +#define L1_CACHE_SHIFT 5UL
73277 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
73278
73279 #endif /* __ASM_GENERIC_CACHE_H */
73280 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
73281 index 0d68a1e..b74a761 100644
73282 --- a/include/asm-generic/emergency-restart.h
73283 +++ b/include/asm-generic/emergency-restart.h
73284 @@ -1,7 +1,7 @@
73285 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
73286 #define _ASM_GENERIC_EMERGENCY_RESTART_H
73287
73288 -static inline void machine_emergency_restart(void)
73289 +static inline __noreturn void machine_emergency_restart(void)
73290 {
73291 machine_restart(NULL);
73292 }
73293 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
73294 index 90f99c7..00ce236 100644
73295 --- a/include/asm-generic/kmap_types.h
73296 +++ b/include/asm-generic/kmap_types.h
73297 @@ -2,9 +2,9 @@
73298 #define _ASM_GENERIC_KMAP_TYPES_H
73299
73300 #ifdef __WITH_KM_FENCE
73301 -# define KM_TYPE_NR 41
73302 +# define KM_TYPE_NR 42
73303 #else
73304 -# define KM_TYPE_NR 20
73305 +# define KM_TYPE_NR 21
73306 #endif
73307
73308 #endif
73309 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
73310 index 9ceb03b..62b0b8f 100644
73311 --- a/include/asm-generic/local.h
73312 +++ b/include/asm-generic/local.h
73313 @@ -23,24 +23,37 @@ typedef struct
73314 atomic_long_t a;
73315 } local_t;
73316
73317 +typedef struct {
73318 + atomic_long_unchecked_t a;
73319 +} local_unchecked_t;
73320 +
73321 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
73322
73323 #define local_read(l) atomic_long_read(&(l)->a)
73324 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
73325 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
73326 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
73327 #define local_inc(l) atomic_long_inc(&(l)->a)
73328 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
73329 #define local_dec(l) atomic_long_dec(&(l)->a)
73330 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
73331 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
73332 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
73333 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
73334 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
73335
73336 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
73337 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
73338 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
73339 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
73340 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
73341 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
73342 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
73343 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
73344 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
73345
73346 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73347 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73348 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
73349 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
73350 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
73351 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
73352 index 725612b..9cc513a 100644
73353 --- a/include/asm-generic/pgtable-nopmd.h
73354 +++ b/include/asm-generic/pgtable-nopmd.h
73355 @@ -1,14 +1,19 @@
73356 #ifndef _PGTABLE_NOPMD_H
73357 #define _PGTABLE_NOPMD_H
73358
73359 -#ifndef __ASSEMBLY__
73360 -
73361 #include <asm-generic/pgtable-nopud.h>
73362
73363 -struct mm_struct;
73364 -
73365 #define __PAGETABLE_PMD_FOLDED
73366
73367 +#define PMD_SHIFT PUD_SHIFT
73368 +#define PTRS_PER_PMD 1
73369 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
73370 +#define PMD_MASK (~(PMD_SIZE-1))
73371 +
73372 +#ifndef __ASSEMBLY__
73373 +
73374 +struct mm_struct;
73375 +
73376 /*
73377 * Having the pmd type consist of a pud gets the size right, and allows
73378 * us to conceptually access the pud entry that this pmd is folded into
73379 @@ -16,11 +21,6 @@ struct mm_struct;
73380 */
73381 typedef struct { pud_t pud; } pmd_t;
73382
73383 -#define PMD_SHIFT PUD_SHIFT
73384 -#define PTRS_PER_PMD 1
73385 -#define PMD_SIZE (1UL << PMD_SHIFT)
73386 -#define PMD_MASK (~(PMD_SIZE-1))
73387 -
73388 /*
73389 * The "pud_xxx()" functions here are trivial for a folded two-level
73390 * setup: the pmd is never bad, and a pmd always exists (as it's folded
73391 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
73392 index 810431d..0ec4804f 100644
73393 --- a/include/asm-generic/pgtable-nopud.h
73394 +++ b/include/asm-generic/pgtable-nopud.h
73395 @@ -1,10 +1,15 @@
73396 #ifndef _PGTABLE_NOPUD_H
73397 #define _PGTABLE_NOPUD_H
73398
73399 -#ifndef __ASSEMBLY__
73400 -
73401 #define __PAGETABLE_PUD_FOLDED
73402
73403 +#define PUD_SHIFT PGDIR_SHIFT
73404 +#define PTRS_PER_PUD 1
73405 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
73406 +#define PUD_MASK (~(PUD_SIZE-1))
73407 +
73408 +#ifndef __ASSEMBLY__
73409 +
73410 /*
73411 * Having the pud type consist of a pgd gets the size right, and allows
73412 * us to conceptually access the pgd entry that this pud is folded into
73413 @@ -12,11 +17,6 @@
73414 */
73415 typedef struct { pgd_t pgd; } pud_t;
73416
73417 -#define PUD_SHIFT PGDIR_SHIFT
73418 -#define PTRS_PER_PUD 1
73419 -#define PUD_SIZE (1UL << PUD_SHIFT)
73420 -#define PUD_MASK (~(PUD_SIZE-1))
73421 -
73422 /*
73423 * The "pgd_xxx()" functions here are trivial for a folded two-level
73424 * setup: the pud is never bad, and a pud always exists (as it's folded
73425 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
73426 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
73427
73428 #define pgd_populate(mm, pgd, pud) do { } while (0)
73429 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
73430 /*
73431 * (puds are folded into pgds so this doesn't get actually called,
73432 * but the define is needed for a generic inline function.)
73433 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
73434 index a59ff51..2594a70 100644
73435 --- a/include/asm-generic/pgtable.h
73436 +++ b/include/asm-generic/pgtable.h
73437 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
73438 }
73439 #endif /* CONFIG_NUMA_BALANCING */
73440
73441 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
73442 +static inline unsigned long pax_open_kernel(void) { return 0; }
73443 +#endif
73444 +
73445 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
73446 +static inline unsigned long pax_close_kernel(void) { return 0; }
73447 +#endif
73448 +
73449 #endif /* CONFIG_MMU */
73450
73451 #endif /* !__ASSEMBLY__ */
73452 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
73453 index c184aa8..d049942 100644
73454 --- a/include/asm-generic/uaccess.h
73455 +++ b/include/asm-generic/uaccess.h
73456 @@ -343,4 +343,12 @@ clear_user(void __user *to, unsigned long n)
73457 return __clear_user(to, n);
73458 }
73459
73460 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
73461 +//static inline unsigned long pax_open_userland(void) { return 0; }
73462 +#endif
73463 +
73464 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
73465 +//static inline unsigned long pax_close_userland(void) { return 0; }
73466 +#endif
73467 +
73468 #endif /* __ASM_GENERIC_UACCESS_H */
73469 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
73470 index eb58d2d..df131bf 100644
73471 --- a/include/asm-generic/vmlinux.lds.h
73472 +++ b/include/asm-generic/vmlinux.lds.h
73473 @@ -239,6 +239,7 @@
73474 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
73475 VMLINUX_SYMBOL(__start_rodata) = .; \
73476 *(.rodata) *(.rodata.*) \
73477 + *(.data..read_only) \
73478 *(__vermagic) /* Kernel version magic */ \
73479 . = ALIGN(8); \
73480 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
73481 @@ -749,17 +750,18 @@
73482 * section in the linker script will go there too. @phdr should have
73483 * a leading colon.
73484 *
73485 - * Note that this macros defines __per_cpu_load as an absolute symbol.
73486 + * Note that this macros defines per_cpu_load as an absolute symbol.
73487 * If there is no need to put the percpu section at a predetermined
73488 * address, use PERCPU_SECTION.
73489 */
73490 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
73491 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73492 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73493 + per_cpu_load = .; \
73494 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73495 - LOAD_OFFSET) { \
73496 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73497 PERCPU_INPUT(cacheline) \
73498 } phdr \
73499 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73500 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73501
73502 /**
73503 * PERCPU_SECTION - define output section for percpu area, simple version
73504 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73505 index 418d270..bfd2794 100644
73506 --- a/include/crypto/algapi.h
73507 +++ b/include/crypto/algapi.h
73508 @@ -34,7 +34,7 @@ struct crypto_type {
73509 unsigned int maskclear;
73510 unsigned int maskset;
73511 unsigned int tfmsize;
73512 -};
73513 +} __do_const;
73514
73515 struct crypto_instance {
73516 struct crypto_alg alg;
73517 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73518 index 63d17ee..716de2b 100644
73519 --- a/include/drm/drmP.h
73520 +++ b/include/drm/drmP.h
73521 @@ -72,6 +72,7 @@
73522 #include <linux/workqueue.h>
73523 #include <linux/poll.h>
73524 #include <asm/pgalloc.h>
73525 +#include <asm/local.h>
73526 #include <drm/drm.h>
73527 #include <drm/drm_sarea.h>
73528
73529 @@ -296,10 +297,12 @@ do { \
73530 * \param cmd command.
73531 * \param arg argument.
73532 */
73533 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73534 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73535 + struct drm_file *file_priv);
73536 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73537 struct drm_file *file_priv);
73538
73539 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73540 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73541 unsigned long arg);
73542
73543 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73544 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73545 struct drm_ioctl_desc {
73546 unsigned int cmd;
73547 int flags;
73548 - drm_ioctl_t *func;
73549 + drm_ioctl_t func;
73550 unsigned int cmd_drv;
73551 const char *name;
73552 -};
73553 +} __do_const;
73554
73555 /**
73556 * Creates a driver or general drm_ioctl_desc array entry for the given
73557 @@ -1015,7 +1018,7 @@ struct drm_info_list {
73558 int (*show)(struct seq_file*, void*); /** show callback */
73559 u32 driver_features; /**< Required driver features for this entry */
73560 void *data;
73561 -};
73562 +} __do_const;
73563
73564 /**
73565 * debugfs node structure. This structure represents a debugfs file.
73566 @@ -1088,7 +1091,7 @@ struct drm_device {
73567
73568 /** \name Usage Counters */
73569 /*@{ */
73570 - int open_count; /**< Outstanding files open */
73571 + local_t open_count; /**< Outstanding files open */
73572 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73573 atomic_t vma_count; /**< Outstanding vma areas open */
73574 int buf_use; /**< Buffers in use -- cannot alloc */
73575 @@ -1099,7 +1102,7 @@ struct drm_device {
73576 /*@{ */
73577 unsigned long counters;
73578 enum drm_stat_type types[15];
73579 - atomic_t counts[15];
73580 + atomic_unchecked_t counts[15];
73581 /*@} */
73582
73583 struct list_head filelist;
73584 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73585 index f43d556..94d9343 100644
73586 --- a/include/drm/drm_crtc_helper.h
73587 +++ b/include/drm/drm_crtc_helper.h
73588 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73589 struct drm_connector *connector);
73590 /* disable encoder when not in use - more explicit than dpms off */
73591 void (*disable)(struct drm_encoder *encoder);
73592 -};
73593 +} __no_const;
73594
73595 /**
73596 * drm_connector_helper_funcs - helper operations for connectors
73597 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73598 index 72dcbe8..8db58d7 100644
73599 --- a/include/drm/ttm/ttm_memory.h
73600 +++ b/include/drm/ttm/ttm_memory.h
73601 @@ -48,7 +48,7 @@
73602
73603 struct ttm_mem_shrink {
73604 int (*do_shrink) (struct ttm_mem_shrink *);
73605 -};
73606 +} __no_const;
73607
73608 /**
73609 * struct ttm_mem_global - Global memory accounting structure.
73610 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73611 index 4b840e8..155d235 100644
73612 --- a/include/keys/asymmetric-subtype.h
73613 +++ b/include/keys/asymmetric-subtype.h
73614 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73615 /* Verify the signature on a key of this subtype (optional) */
73616 int (*verify_signature)(const struct key *key,
73617 const struct public_key_signature *sig);
73618 -};
73619 +} __do_const;
73620
73621 /**
73622 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73623 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73624 index c1da539..1dcec55 100644
73625 --- a/include/linux/atmdev.h
73626 +++ b/include/linux/atmdev.h
73627 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73628 #endif
73629
73630 struct k_atm_aal_stats {
73631 -#define __HANDLE_ITEM(i) atomic_t i
73632 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73633 __AAL_STAT_ITEMS
73634 #undef __HANDLE_ITEM
73635 };
73636 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73637 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73638 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73639 struct module *owner;
73640 -};
73641 +} __do_const ;
73642
73643 struct atmphy_ops {
73644 int (*start)(struct atm_dev *dev);
73645 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73646 index 70cf138..0418ee2 100644
73647 --- a/include/linux/binfmts.h
73648 +++ b/include/linux/binfmts.h
73649 @@ -73,8 +73,10 @@ struct linux_binfmt {
73650 int (*load_binary)(struct linux_binprm *);
73651 int (*load_shlib)(struct file *);
73652 int (*core_dump)(struct coredump_params *cprm);
73653 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73654 + void (*handle_mmap)(struct file *);
73655 unsigned long min_coredump; /* minimal dump size */
73656 -};
73657 +} __do_const;
73658
73659 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73660
73661 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73662 index 2fdb4a4..54aad7e 100644
73663 --- a/include/linux/blkdev.h
73664 +++ b/include/linux/blkdev.h
73665 @@ -1526,7 +1526,7 @@ struct block_device_operations {
73666 /* this callback is with swap_lock and sometimes page table lock held */
73667 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73668 struct module *owner;
73669 -};
73670 +} __do_const;
73671
73672 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73673 unsigned long);
73674 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73675 index 7c2e030..b72475d 100644
73676 --- a/include/linux/blktrace_api.h
73677 +++ b/include/linux/blktrace_api.h
73678 @@ -23,7 +23,7 @@ struct blk_trace {
73679 struct dentry *dir;
73680 struct dentry *dropped_file;
73681 struct dentry *msg_file;
73682 - atomic_t dropped;
73683 + atomic_unchecked_t dropped;
73684 };
73685
73686 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
73687 diff --git a/include/linux/cache.h b/include/linux/cache.h
73688 index 4c57065..4307975 100644
73689 --- a/include/linux/cache.h
73690 +++ b/include/linux/cache.h
73691 @@ -16,6 +16,10 @@
73692 #define __read_mostly
73693 #endif
73694
73695 +#ifndef __read_only
73696 +#define __read_only __read_mostly
73697 +#endif
73698 +
73699 #ifndef ____cacheline_aligned
73700 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
73701 #endif
73702 diff --git a/include/linux/capability.h b/include/linux/capability.h
73703 index d9a4f7f4..19f77d6 100644
73704 --- a/include/linux/capability.h
73705 +++ b/include/linux/capability.h
73706 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
73707 extern bool nsown_capable(int cap);
73708 extern bool inode_capable(const struct inode *inode, int cap);
73709 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
73710 +extern bool capable_nolog(int cap);
73711 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
73712 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
73713
73714 /* audit system wants to get cap info from files as well */
73715 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
73716
73717 +extern int is_privileged_binary(const struct dentry *dentry);
73718 +
73719 #endif /* !_LINUX_CAPABILITY_H */
73720 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
73721 index 8609d57..86e4d79 100644
73722 --- a/include/linux/cdrom.h
73723 +++ b/include/linux/cdrom.h
73724 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
73725
73726 /* driver specifications */
73727 const int capability; /* capability flags */
73728 - int n_minors; /* number of active minor devices */
73729 /* handle uniform packets for scsi type devices (scsi,atapi) */
73730 int (*generic_packet) (struct cdrom_device_info *,
73731 struct packet_command *);
73732 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
73733 index 4ce9056..86caac6 100644
73734 --- a/include/linux/cleancache.h
73735 +++ b/include/linux/cleancache.h
73736 @@ -31,7 +31,7 @@ struct cleancache_ops {
73737 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
73738 void (*invalidate_inode)(int, struct cleancache_filekey);
73739 void (*invalidate_fs)(int);
73740 -};
73741 +} __no_const;
73742
73743 extern struct cleancache_ops *
73744 cleancache_register_ops(struct cleancache_ops *ops);
73745 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
73746 index 1186098..f87e53d 100644
73747 --- a/include/linux/clk-provider.h
73748 +++ b/include/linux/clk-provider.h
73749 @@ -132,6 +132,7 @@ struct clk_ops {
73750 unsigned long);
73751 void (*init)(struct clk_hw *hw);
73752 };
73753 +typedef struct clk_ops __no_const clk_ops_no_const;
73754
73755 /**
73756 * struct clk_init_data - holds init data that's common to all clocks and is
73757 diff --git a/include/linux/compat.h b/include/linux/compat.h
73758 index 7f0c1dd..206ac34 100644
73759 --- a/include/linux/compat.h
73760 +++ b/include/linux/compat.h
73761 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
73762 compat_size_t __user *len_ptr);
73763
73764 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
73765 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
73766 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
73767 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
73768 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
73769 compat_ssize_t msgsz, int msgflg);
73770 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
73771 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73772 compat_ulong_t addr, compat_ulong_t data);
73773 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
73774 - compat_long_t addr, compat_long_t data);
73775 + compat_ulong_t addr, compat_ulong_t data);
73776
73777 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
73778 /*
73779 @@ -669,6 +669,7 @@ asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
73780
73781 int compat_restore_altstack(const compat_stack_t __user *uss);
73782 int __compat_save_altstack(compat_stack_t __user *, unsigned long);
73783 +void __compat_save_altstack_ex(compat_stack_t __user *, unsigned long);
73784
73785 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
73786 struct compat_timespec __user *interval);
73787 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
73788 index 842de22..7f3a41f 100644
73789 --- a/include/linux/compiler-gcc4.h
73790 +++ b/include/linux/compiler-gcc4.h
73791 @@ -39,9 +39,29 @@
73792 # define __compiletime_warning(message) __attribute__((warning(message)))
73793 # define __compiletime_error(message) __attribute__((error(message)))
73794 #endif /* __CHECKER__ */
73795 +
73796 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
73797 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
73798 +#define __bos0(ptr) __bos((ptr), 0)
73799 +#define __bos1(ptr) __bos((ptr), 1)
73800 #endif /* GCC_VERSION >= 40300 */
73801
73802 #if GCC_VERSION >= 40500
73803 +
73804 +#ifdef CONSTIFY_PLUGIN
73805 +#define __no_const __attribute__((no_const))
73806 +#define __do_const __attribute__((do_const))
73807 +#endif
73808 +
73809 +#ifdef SIZE_OVERFLOW_PLUGIN
73810 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
73811 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
73812 +#endif
73813 +
73814 +#ifdef LATENT_ENTROPY_PLUGIN
73815 +#define __latent_entropy __attribute__((latent_entropy))
73816 +#endif
73817 +
73818 /*
73819 * Mark a position in code as unreachable. This can be used to
73820 * suppress control flow warnings after asm blocks that transfer
73821 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
73822 index 92669cd..1771a15 100644
73823 --- a/include/linux/compiler.h
73824 +++ b/include/linux/compiler.h
73825 @@ -5,11 +5,14 @@
73826
73827 #ifdef __CHECKER__
73828 # define __user __attribute__((noderef, address_space(1)))
73829 +# define __force_user __force __user
73830 # define __kernel __attribute__((address_space(0)))
73831 +# define __force_kernel __force __kernel
73832 # define __safe __attribute__((safe))
73833 # define __force __attribute__((force))
73834 # define __nocast __attribute__((nocast))
73835 # define __iomem __attribute__((noderef, address_space(2)))
73836 +# define __force_iomem __force __iomem
73837 # define __must_hold(x) __attribute__((context(x,1,1)))
73838 # define __acquires(x) __attribute__((context(x,0,1)))
73839 # define __releases(x) __attribute__((context(x,1,0)))
73840 @@ -17,20 +20,37 @@
73841 # define __release(x) __context__(x,-1)
73842 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
73843 # define __percpu __attribute__((noderef, address_space(3)))
73844 +# define __force_percpu __force __percpu
73845 #ifdef CONFIG_SPARSE_RCU_POINTER
73846 # define __rcu __attribute__((noderef, address_space(4)))
73847 +# define __force_rcu __force __rcu
73848 #else
73849 # define __rcu
73850 +# define __force_rcu
73851 #endif
73852 extern void __chk_user_ptr(const volatile void __user *);
73853 extern void __chk_io_ptr(const volatile void __iomem *);
73854 #else
73855 -# define __user
73856 -# define __kernel
73857 +# ifdef CHECKER_PLUGIN
73858 +//# define __user
73859 +//# define __force_user
73860 +//# define __kernel
73861 +//# define __force_kernel
73862 +# else
73863 +# ifdef STRUCTLEAK_PLUGIN
73864 +# define __user __attribute__((user))
73865 +# else
73866 +# define __user
73867 +# endif
73868 +# define __force_user
73869 +# define __kernel
73870 +# define __force_kernel
73871 +# endif
73872 # define __safe
73873 # define __force
73874 # define __nocast
73875 # define __iomem
73876 +# define __force_iomem
73877 # define __chk_user_ptr(x) (void)0
73878 # define __chk_io_ptr(x) (void)0
73879 # define __builtin_warning(x, y...) (1)
73880 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
73881 # define __release(x) (void)0
73882 # define __cond_lock(x,c) (c)
73883 # define __percpu
73884 +# define __force_percpu
73885 # define __rcu
73886 +# define __force_rcu
73887 #endif
73888
73889 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
73890 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73891 # define __attribute_const__ /* unimplemented */
73892 #endif
73893
73894 +#ifndef __no_const
73895 +# define __no_const
73896 +#endif
73897 +
73898 +#ifndef __do_const
73899 +# define __do_const
73900 +#endif
73901 +
73902 +#ifndef __size_overflow
73903 +# define __size_overflow(...)
73904 +#endif
73905 +
73906 +#ifndef __intentional_overflow
73907 +# define __intentional_overflow(...)
73908 +#endif
73909 +
73910 +#ifndef __latent_entropy
73911 +# define __latent_entropy
73912 +#endif
73913 +
73914 /*
73915 * Tell gcc if a function is cold. The compiler will assume any path
73916 * directly leading to the call is unlikely.
73917 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73918 #define __cold
73919 #endif
73920
73921 +#ifndef __alloc_size
73922 +#define __alloc_size(...)
73923 +#endif
73924 +
73925 +#ifndef __bos
73926 +#define __bos(ptr, arg)
73927 +#endif
73928 +
73929 +#ifndef __bos0
73930 +#define __bos0(ptr)
73931 +#endif
73932 +
73933 +#ifndef __bos1
73934 +#define __bos1(ptr)
73935 +#endif
73936 +
73937 /* Simple shorthand for a section definition */
73938 #ifndef __section
73939 # define __section(S) __attribute__ ((__section__(#S)))
73940 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73941 * use is to mediate communication between process-level code and irq/NMI
73942 * handlers, all running on the same CPU.
73943 */
73944 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
73945 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
73946 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
73947
73948 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
73949 #ifdef CONFIG_KPROBES
73950 diff --git a/include/linux/completion.h b/include/linux/completion.h
73951 index 33f0280..35c6568 100644
73952 --- a/include/linux/completion.h
73953 +++ b/include/linux/completion.h
73954 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
73955 extern void wait_for_completion(struct completion *);
73956 extern void wait_for_completion_io(struct completion *);
73957 extern int wait_for_completion_interruptible(struct completion *x);
73958 -extern int wait_for_completion_killable(struct completion *x);
73959 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
73960 extern unsigned long wait_for_completion_timeout(struct completion *x,
73961 unsigned long timeout);
73962 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
73963 unsigned long timeout);
73964 extern long wait_for_completion_interruptible_timeout(
73965 - struct completion *x, unsigned long timeout);
73966 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73967 extern long wait_for_completion_killable_timeout(
73968 - struct completion *x, unsigned long timeout);
73969 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73970 extern bool try_wait_for_completion(struct completion *x);
73971 extern bool completion_done(struct completion *x);
73972
73973 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
73974 index 34025df..d94bbbc 100644
73975 --- a/include/linux/configfs.h
73976 +++ b/include/linux/configfs.h
73977 @@ -125,7 +125,7 @@ struct configfs_attribute {
73978 const char *ca_name;
73979 struct module *ca_owner;
73980 umode_t ca_mode;
73981 -};
73982 +} __do_const;
73983
73984 /*
73985 * Users often need to create attribute structures for their configurable
73986 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
73987 index 9f3c7e8..a18c7b6 100644
73988 --- a/include/linux/cpu.h
73989 +++ b/include/linux/cpu.h
73990 @@ -115,7 +115,7 @@ enum {
73991 /* Need to know about CPUs going up/down? */
73992 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
73993 #define cpu_notifier(fn, pri) { \
73994 - static struct notifier_block fn##_nb __cpuinitdata = \
73995 + static struct notifier_block fn##_nb = \
73996 { .notifier_call = fn, .priority = pri }; \
73997 register_cpu_notifier(&fn##_nb); \
73998 }
73999 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
74000 index 037d36a..ca5fe6e 100644
74001 --- a/include/linux/cpufreq.h
74002 +++ b/include/linux/cpufreq.h
74003 @@ -262,7 +262,7 @@ struct cpufreq_driver {
74004 int (*suspend) (struct cpufreq_policy *policy);
74005 int (*resume) (struct cpufreq_policy *policy);
74006 struct freq_attr **attr;
74007 -};
74008 +} __do_const;
74009
74010 /* flags */
74011
74012 @@ -321,6 +321,7 @@ struct global_attr {
74013 ssize_t (*store)(struct kobject *a, struct attribute *b,
74014 const char *c, size_t count);
74015 };
74016 +typedef struct global_attr __no_const global_attr_no_const;
74017
74018 #define define_one_global_ro(_name) \
74019 static struct global_attr _name = \
74020 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
74021 index 8f04062..900239a 100644
74022 --- a/include/linux/cpuidle.h
74023 +++ b/include/linux/cpuidle.h
74024 @@ -52,7 +52,8 @@ struct cpuidle_state {
74025 int index);
74026
74027 int (*enter_dead) (struct cpuidle_device *dev, int index);
74028 -};
74029 +} __do_const;
74030 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
74031
74032 /* Idle State Flags */
74033 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
74034 @@ -191,7 +192,7 @@ struct cpuidle_governor {
74035 void (*reflect) (struct cpuidle_device *dev, int index);
74036
74037 struct module *owner;
74038 -};
74039 +} __do_const;
74040
74041 #ifdef CONFIG_CPU_IDLE
74042
74043 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
74044 index d08e4d2..95fad61 100644
74045 --- a/include/linux/cpumask.h
74046 +++ b/include/linux/cpumask.h
74047 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74048 }
74049
74050 /* Valid inputs for n are -1 and 0. */
74051 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74052 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74053 {
74054 return n+1;
74055 }
74056
74057 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74058 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74059 {
74060 return n+1;
74061 }
74062
74063 -static inline unsigned int cpumask_next_and(int n,
74064 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
74065 const struct cpumask *srcp,
74066 const struct cpumask *andp)
74067 {
74068 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74069 *
74070 * Returns >= nr_cpu_ids if no further cpus set.
74071 */
74072 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74073 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74074 {
74075 /* -1 is a legal arg here. */
74076 if (n != -1)
74077 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74078 *
74079 * Returns >= nr_cpu_ids if no further cpus unset.
74080 */
74081 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74082 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74083 {
74084 /* -1 is a legal arg here. */
74085 if (n != -1)
74086 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74087 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
74088 }
74089
74090 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
74091 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
74092 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
74093
74094 /**
74095 diff --git a/include/linux/cred.h b/include/linux/cred.h
74096 index 04421e8..6bce4ef 100644
74097 --- a/include/linux/cred.h
74098 +++ b/include/linux/cred.h
74099 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
74100 static inline void validate_process_creds(void)
74101 {
74102 }
74103 +static inline void validate_task_creds(struct task_struct *task)
74104 +{
74105 +}
74106 #endif
74107
74108 /**
74109 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
74110 index b92eadf..b4ecdc1 100644
74111 --- a/include/linux/crypto.h
74112 +++ b/include/linux/crypto.h
74113 @@ -373,7 +373,7 @@ struct cipher_tfm {
74114 const u8 *key, unsigned int keylen);
74115 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74116 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74117 -};
74118 +} __no_const;
74119
74120 struct hash_tfm {
74121 int (*init)(struct hash_desc *desc);
74122 @@ -394,13 +394,13 @@ struct compress_tfm {
74123 int (*cot_decompress)(struct crypto_tfm *tfm,
74124 const u8 *src, unsigned int slen,
74125 u8 *dst, unsigned int *dlen);
74126 -};
74127 +} __no_const;
74128
74129 struct rng_tfm {
74130 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
74131 unsigned int dlen);
74132 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
74133 -};
74134 +} __no_const;
74135
74136 #define crt_ablkcipher crt_u.ablkcipher
74137 #define crt_aead crt_u.aead
74138 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
74139 index 653589e..4ef254a 100644
74140 --- a/include/linux/ctype.h
74141 +++ b/include/linux/ctype.h
74142 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
74143 * Fast implementation of tolower() for internal usage. Do not use in your
74144 * code.
74145 */
74146 -static inline char _tolower(const char c)
74147 +static inline unsigned char _tolower(const unsigned char c)
74148 {
74149 return c | 0x20;
74150 }
74151 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
74152 index 7925bf0..d5143d2 100644
74153 --- a/include/linux/decompress/mm.h
74154 +++ b/include/linux/decompress/mm.h
74155 @@ -77,7 +77,7 @@ static void free(void *where)
74156 * warnings when not needed (indeed large_malloc / large_free are not
74157 * needed by inflate */
74158
74159 -#define malloc(a) kmalloc(a, GFP_KERNEL)
74160 +#define malloc(a) kmalloc((a), GFP_KERNEL)
74161 #define free(a) kfree(a)
74162
74163 #define large_malloc(a) vmalloc(a)
74164 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
74165 index fe8c447..bdc1f33 100644
74166 --- a/include/linux/devfreq.h
74167 +++ b/include/linux/devfreq.h
74168 @@ -114,7 +114,7 @@ struct devfreq_governor {
74169 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
74170 int (*event_handler)(struct devfreq *devfreq,
74171 unsigned int event, void *data);
74172 -};
74173 +} __do_const;
74174
74175 /**
74176 * struct devfreq - Device devfreq structure
74177 diff --git a/include/linux/device.h b/include/linux/device.h
74178 index c0a1261..dba7569 100644
74179 --- a/include/linux/device.h
74180 +++ b/include/linux/device.h
74181 @@ -290,7 +290,7 @@ struct subsys_interface {
74182 struct list_head node;
74183 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
74184 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
74185 -};
74186 +} __do_const;
74187
74188 int subsys_interface_register(struct subsys_interface *sif);
74189 void subsys_interface_unregister(struct subsys_interface *sif);
74190 @@ -473,7 +473,7 @@ struct device_type {
74191 void (*release)(struct device *dev);
74192
74193 const struct dev_pm_ops *pm;
74194 -};
74195 +} __do_const;
74196
74197 /* interface for exporting device attributes */
74198 struct device_attribute {
74199 @@ -483,11 +483,12 @@ struct device_attribute {
74200 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
74201 const char *buf, size_t count);
74202 };
74203 +typedef struct device_attribute __no_const device_attribute_no_const;
74204
74205 struct dev_ext_attribute {
74206 struct device_attribute attr;
74207 void *var;
74208 -};
74209 +} __do_const;
74210
74211 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
74212 char *buf);
74213 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
74214 index 94af418..b1ca7a2 100644
74215 --- a/include/linux/dma-mapping.h
74216 +++ b/include/linux/dma-mapping.h
74217 @@ -54,7 +54,7 @@ struct dma_map_ops {
74218 u64 (*get_required_mask)(struct device *dev);
74219 #endif
74220 int is_phys;
74221 -};
74222 +} __do_const;
74223
74224 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
74225
74226 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
74227 index 96d3e4a..dc36433 100644
74228 --- a/include/linux/dmaengine.h
74229 +++ b/include/linux/dmaengine.h
74230 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
74231 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
74232 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
74233
74234 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74235 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74236 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
74237 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74238 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74239 struct dma_pinned_list *pinned_list, struct page *page,
74240 unsigned int offset, size_t len);
74241
74242 diff --git a/include/linux/efi.h b/include/linux/efi.h
74243 index 2bc0ad7..3f7b006 100644
74244 --- a/include/linux/efi.h
74245 +++ b/include/linux/efi.h
74246 @@ -745,6 +745,7 @@ struct efivar_operations {
74247 efi_set_variable_t *set_variable;
74248 efi_query_variable_store_t *query_variable_store;
74249 };
74250 +typedef struct efivar_operations __no_const efivar_operations_no_const;
74251
74252 struct efivars {
74253 /*
74254 diff --git a/include/linux/elf.h b/include/linux/elf.h
74255 index 40a3c0e..4c45a38 100644
74256 --- a/include/linux/elf.h
74257 +++ b/include/linux/elf.h
74258 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
74259 #define elf_note elf32_note
74260 #define elf_addr_t Elf32_Off
74261 #define Elf_Half Elf32_Half
74262 +#define elf_dyn Elf32_Dyn
74263
74264 #else
74265
74266 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
74267 #define elf_note elf64_note
74268 #define elf_addr_t Elf64_Off
74269 #define Elf_Half Elf64_Half
74270 +#define elf_dyn Elf64_Dyn
74271
74272 #endif
74273
74274 diff --git a/include/linux/err.h b/include/linux/err.h
74275 index f2edce2..cc2082c 100644
74276 --- a/include/linux/err.h
74277 +++ b/include/linux/err.h
74278 @@ -19,12 +19,12 @@
74279
74280 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
74281
74282 -static inline void * __must_check ERR_PTR(long error)
74283 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
74284 {
74285 return (void *) error;
74286 }
74287
74288 -static inline long __must_check PTR_ERR(const void *ptr)
74289 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
74290 {
74291 return (long) ptr;
74292 }
74293 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
74294 index fcb51c8..bdafcf6 100644
74295 --- a/include/linux/extcon.h
74296 +++ b/include/linux/extcon.h
74297 @@ -134,7 +134,7 @@ struct extcon_dev {
74298 /* /sys/class/extcon/.../mutually_exclusive/... */
74299 struct attribute_group attr_g_muex;
74300 struct attribute **attrs_muex;
74301 - struct device_attribute *d_attrs_muex;
74302 + device_attribute_no_const *d_attrs_muex;
74303 };
74304
74305 /**
74306 diff --git a/include/linux/fb.h b/include/linux/fb.h
74307 index d49c60f..2834fbe 100644
74308 --- a/include/linux/fb.h
74309 +++ b/include/linux/fb.h
74310 @@ -304,7 +304,7 @@ struct fb_ops {
74311 /* called at KDB enter and leave time to prepare the console */
74312 int (*fb_debug_enter)(struct fb_info *info);
74313 int (*fb_debug_leave)(struct fb_info *info);
74314 -};
74315 +} __do_const;
74316
74317 #ifdef CONFIG_FB_TILEBLITTING
74318 #define FB_TILE_CURSOR_NONE 0
74319 diff --git a/include/linux/filter.h b/include/linux/filter.h
74320 index f65f5a6..2f4f93a 100644
74321 --- a/include/linux/filter.h
74322 +++ b/include/linux/filter.h
74323 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
74324
74325 struct sk_buff;
74326 struct sock;
74327 +struct bpf_jit_work;
74328
74329 struct sk_filter
74330 {
74331 @@ -27,6 +28,9 @@ struct sk_filter
74332 unsigned int len; /* Number of filter blocks */
74333 unsigned int (*bpf_func)(const struct sk_buff *skb,
74334 const struct sock_filter *filter);
74335 +#ifdef CONFIG_BPF_JIT
74336 + struct bpf_jit_work *work;
74337 +#endif
74338 struct rcu_head rcu;
74339 struct sock_filter insns[0];
74340 };
74341 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
74342 index 8293262..2b3b8bd 100644
74343 --- a/include/linux/frontswap.h
74344 +++ b/include/linux/frontswap.h
74345 @@ -11,7 +11,7 @@ struct frontswap_ops {
74346 int (*load)(unsigned, pgoff_t, struct page *);
74347 void (*invalidate_page)(unsigned, pgoff_t);
74348 void (*invalidate_area)(unsigned);
74349 -};
74350 +} __no_const;
74351
74352 extern bool frontswap_enabled;
74353 extern struct frontswap_ops *
74354 diff --git a/include/linux/fs.h b/include/linux/fs.h
74355 index 65c2be2..4c53f6e 100644
74356 --- a/include/linux/fs.h
74357 +++ b/include/linux/fs.h
74358 @@ -1543,7 +1543,8 @@ struct file_operations {
74359 long (*fallocate)(struct file *file, int mode, loff_t offset,
74360 loff_t len);
74361 int (*show_fdinfo)(struct seq_file *m, struct file *f);
74362 -};
74363 +} __do_const;
74364 +typedef struct file_operations __no_const file_operations_no_const;
74365
74366 struct inode_operations {
74367 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
74368 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
74369 inode->i_flags |= S_NOSEC;
74370 }
74371
74372 +static inline bool is_sidechannel_device(const struct inode *inode)
74373 +{
74374 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
74375 + umode_t mode = inode->i_mode;
74376 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
74377 +#else
74378 + return false;
74379 +#endif
74380 +}
74381 +
74382 #endif /* _LINUX_FS_H */
74383 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
74384 index 2b93a9a..855d94a 100644
74385 --- a/include/linux/fs_struct.h
74386 +++ b/include/linux/fs_struct.h
74387 @@ -6,7 +6,7 @@
74388 #include <linux/seqlock.h>
74389
74390 struct fs_struct {
74391 - int users;
74392 + atomic_t users;
74393 spinlock_t lock;
74394 seqcount_t seq;
74395 int umask;
74396 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
74397 index 5dfa0aa..6acf322 100644
74398 --- a/include/linux/fscache-cache.h
74399 +++ b/include/linux/fscache-cache.h
74400 @@ -112,7 +112,7 @@ struct fscache_operation {
74401 fscache_operation_release_t release;
74402 };
74403
74404 -extern atomic_t fscache_op_debug_id;
74405 +extern atomic_unchecked_t fscache_op_debug_id;
74406 extern void fscache_op_work_func(struct work_struct *work);
74407
74408 extern void fscache_enqueue_operation(struct fscache_operation *);
74409 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
74410 INIT_WORK(&op->work, fscache_op_work_func);
74411 atomic_set(&op->usage, 1);
74412 op->state = FSCACHE_OP_ST_INITIALISED;
74413 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
74414 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
74415 op->processor = processor;
74416 op->release = release;
74417 INIT_LIST_HEAD(&op->pend_link);
74418 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
74419 index 7a08623..4c07b0f 100644
74420 --- a/include/linux/fscache.h
74421 +++ b/include/linux/fscache.h
74422 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
74423 * - this is mandatory for any object that may have data
74424 */
74425 void (*now_uncached)(void *cookie_netfs_data);
74426 -};
74427 +} __do_const;
74428
74429 /*
74430 * fscache cached network filesystem type
74431 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
74432 index a78680a..87bd73e 100644
74433 --- a/include/linux/fsnotify.h
74434 +++ b/include/linux/fsnotify.h
74435 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
74436 struct inode *inode = path->dentry->d_inode;
74437 __u32 mask = FS_ACCESS;
74438
74439 + if (is_sidechannel_device(inode))
74440 + return;
74441 +
74442 if (S_ISDIR(inode->i_mode))
74443 mask |= FS_ISDIR;
74444
74445 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
74446 struct inode *inode = path->dentry->d_inode;
74447 __u32 mask = FS_MODIFY;
74448
74449 + if (is_sidechannel_device(inode))
74450 + return;
74451 +
74452 if (S_ISDIR(inode->i_mode))
74453 mask |= FS_ISDIR;
74454
74455 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
74456 */
74457 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
74458 {
74459 - return kstrdup(name, GFP_KERNEL);
74460 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
74461 }
74462
74463 /*
74464 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
74465 index 9f3c275..911b591 100644
74466 --- a/include/linux/genhd.h
74467 +++ b/include/linux/genhd.h
74468 @@ -194,7 +194,7 @@ struct gendisk {
74469 struct kobject *slave_dir;
74470
74471 struct timer_rand_state *random;
74472 - atomic_t sync_io; /* RAID */
74473 + atomic_unchecked_t sync_io; /* RAID */
74474 struct disk_events *ev;
74475 #ifdef CONFIG_BLK_DEV_INTEGRITY
74476 struct blk_integrity *integrity;
74477 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74478 index 023bc34..b02b46a 100644
74479 --- a/include/linux/genl_magic_func.h
74480 +++ b/include/linux/genl_magic_func.h
74481 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74482 },
74483
74484 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74485 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74486 +static struct genl_ops ZZZ_genl_ops[] = {
74487 #include GENL_MAGIC_INCLUDE_FILE
74488 };
74489
74490 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74491 index 0f615eb..5c3832f 100644
74492 --- a/include/linux/gfp.h
74493 +++ b/include/linux/gfp.h
74494 @@ -35,6 +35,13 @@ struct vm_area_struct;
74495 #define ___GFP_NO_KSWAPD 0x400000u
74496 #define ___GFP_OTHER_NODE 0x800000u
74497 #define ___GFP_WRITE 0x1000000u
74498 +
74499 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74500 +#define ___GFP_USERCOPY 0x2000000u
74501 +#else
74502 +#define ___GFP_USERCOPY 0
74503 +#endif
74504 +
74505 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74506
74507 /*
74508 @@ -92,6 +99,7 @@ struct vm_area_struct;
74509 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74510 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74511 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74512 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74513
74514 /*
74515 * This may seem redundant, but it's a way of annotating false positives vs.
74516 @@ -99,7 +107,7 @@ struct vm_area_struct;
74517 */
74518 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74519
74520 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74521 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74522 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74523
74524 /* This equals 0, but use constants in case they ever change */
74525 @@ -153,6 +161,8 @@ struct vm_area_struct;
74526 /* 4GB DMA on some platforms */
74527 #define GFP_DMA32 __GFP_DMA32
74528
74529 +#define GFP_USERCOPY __GFP_USERCOPY
74530 +
74531 /* Convert GFP flags to their corresponding migrate type */
74532 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74533 {
74534 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74535 new file mode 100644
74536 index 0000000..ebe6d72
74537 --- /dev/null
74538 +++ b/include/linux/gracl.h
74539 @@ -0,0 +1,319 @@
74540 +#ifndef GR_ACL_H
74541 +#define GR_ACL_H
74542 +
74543 +#include <linux/grdefs.h>
74544 +#include <linux/resource.h>
74545 +#include <linux/capability.h>
74546 +#include <linux/dcache.h>
74547 +#include <asm/resource.h>
74548 +
74549 +/* Major status information */
74550 +
74551 +#define GR_VERSION "grsecurity 2.9.1"
74552 +#define GRSECURITY_VERSION 0x2901
74553 +
74554 +enum {
74555 + GR_SHUTDOWN = 0,
74556 + GR_ENABLE = 1,
74557 + GR_SPROLE = 2,
74558 + GR_RELOAD = 3,
74559 + GR_SEGVMOD = 4,
74560 + GR_STATUS = 5,
74561 + GR_UNSPROLE = 6,
74562 + GR_PASSSET = 7,
74563 + GR_SPROLEPAM = 8,
74564 +};
74565 +
74566 +/* Password setup definitions
74567 + * kernel/grhash.c */
74568 +enum {
74569 + GR_PW_LEN = 128,
74570 + GR_SALT_LEN = 16,
74571 + GR_SHA_LEN = 32,
74572 +};
74573 +
74574 +enum {
74575 + GR_SPROLE_LEN = 64,
74576 +};
74577 +
74578 +enum {
74579 + GR_NO_GLOB = 0,
74580 + GR_REG_GLOB,
74581 + GR_CREATE_GLOB
74582 +};
74583 +
74584 +#define GR_NLIMITS 32
74585 +
74586 +/* Begin Data Structures */
74587 +
74588 +struct sprole_pw {
74589 + unsigned char *rolename;
74590 + unsigned char salt[GR_SALT_LEN];
74591 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74592 +};
74593 +
74594 +struct name_entry {
74595 + __u32 key;
74596 + ino_t inode;
74597 + dev_t device;
74598 + char *name;
74599 + __u16 len;
74600 + __u8 deleted;
74601 + struct name_entry *prev;
74602 + struct name_entry *next;
74603 +};
74604 +
74605 +struct inodev_entry {
74606 + struct name_entry *nentry;
74607 + struct inodev_entry *prev;
74608 + struct inodev_entry *next;
74609 +};
74610 +
74611 +struct acl_role_db {
74612 + struct acl_role_label **r_hash;
74613 + __u32 r_size;
74614 +};
74615 +
74616 +struct inodev_db {
74617 + struct inodev_entry **i_hash;
74618 + __u32 i_size;
74619 +};
74620 +
74621 +struct name_db {
74622 + struct name_entry **n_hash;
74623 + __u32 n_size;
74624 +};
74625 +
74626 +struct crash_uid {
74627 + uid_t uid;
74628 + unsigned long expires;
74629 +};
74630 +
74631 +struct gr_hash_struct {
74632 + void **table;
74633 + void **nametable;
74634 + void *first;
74635 + __u32 table_size;
74636 + __u32 used_size;
74637 + int type;
74638 +};
74639 +
74640 +/* Userspace Grsecurity ACL data structures */
74641 +
74642 +struct acl_subject_label {
74643 + char *filename;
74644 + ino_t inode;
74645 + dev_t device;
74646 + __u32 mode;
74647 + kernel_cap_t cap_mask;
74648 + kernel_cap_t cap_lower;
74649 + kernel_cap_t cap_invert_audit;
74650 +
74651 + struct rlimit res[GR_NLIMITS];
74652 + __u32 resmask;
74653 +
74654 + __u8 user_trans_type;
74655 + __u8 group_trans_type;
74656 + uid_t *user_transitions;
74657 + gid_t *group_transitions;
74658 + __u16 user_trans_num;
74659 + __u16 group_trans_num;
74660 +
74661 + __u32 sock_families[2];
74662 + __u32 ip_proto[8];
74663 + __u32 ip_type;
74664 + struct acl_ip_label **ips;
74665 + __u32 ip_num;
74666 + __u32 inaddr_any_override;
74667 +
74668 + __u32 crashes;
74669 + unsigned long expires;
74670 +
74671 + struct acl_subject_label *parent_subject;
74672 + struct gr_hash_struct *hash;
74673 + struct acl_subject_label *prev;
74674 + struct acl_subject_label *next;
74675 +
74676 + struct acl_object_label **obj_hash;
74677 + __u32 obj_hash_size;
74678 + __u16 pax_flags;
74679 +};
74680 +
74681 +struct role_allowed_ip {
74682 + __u32 addr;
74683 + __u32 netmask;
74684 +
74685 + struct role_allowed_ip *prev;
74686 + struct role_allowed_ip *next;
74687 +};
74688 +
74689 +struct role_transition {
74690 + char *rolename;
74691 +
74692 + struct role_transition *prev;
74693 + struct role_transition *next;
74694 +};
74695 +
74696 +struct acl_role_label {
74697 + char *rolename;
74698 + uid_t uidgid;
74699 + __u16 roletype;
74700 +
74701 + __u16 auth_attempts;
74702 + unsigned long expires;
74703 +
74704 + struct acl_subject_label *root_label;
74705 + struct gr_hash_struct *hash;
74706 +
74707 + struct acl_role_label *prev;
74708 + struct acl_role_label *next;
74709 +
74710 + struct role_transition *transitions;
74711 + struct role_allowed_ip *allowed_ips;
74712 + uid_t *domain_children;
74713 + __u16 domain_child_num;
74714 +
74715 + umode_t umask;
74716 +
74717 + struct acl_subject_label **subj_hash;
74718 + __u32 subj_hash_size;
74719 +};
74720 +
74721 +struct user_acl_role_db {
74722 + struct acl_role_label **r_table;
74723 + __u32 num_pointers; /* Number of allocations to track */
74724 + __u32 num_roles; /* Number of roles */
74725 + __u32 num_domain_children; /* Number of domain children */
74726 + __u32 num_subjects; /* Number of subjects */
74727 + __u32 num_objects; /* Number of objects */
74728 +};
74729 +
74730 +struct acl_object_label {
74731 + char *filename;
74732 + ino_t inode;
74733 + dev_t device;
74734 + __u32 mode;
74735 +
74736 + struct acl_subject_label *nested;
74737 + struct acl_object_label *globbed;
74738 +
74739 + /* next two structures not used */
74740 +
74741 + struct acl_object_label *prev;
74742 + struct acl_object_label *next;
74743 +};
74744 +
74745 +struct acl_ip_label {
74746 + char *iface;
74747 + __u32 addr;
74748 + __u32 netmask;
74749 + __u16 low, high;
74750 + __u8 mode;
74751 + __u32 type;
74752 + __u32 proto[8];
74753 +
74754 + /* next two structures not used */
74755 +
74756 + struct acl_ip_label *prev;
74757 + struct acl_ip_label *next;
74758 +};
74759 +
74760 +struct gr_arg {
74761 + struct user_acl_role_db role_db;
74762 + unsigned char pw[GR_PW_LEN];
74763 + unsigned char salt[GR_SALT_LEN];
74764 + unsigned char sum[GR_SHA_LEN];
74765 + unsigned char sp_role[GR_SPROLE_LEN];
74766 + struct sprole_pw *sprole_pws;
74767 + dev_t segv_device;
74768 + ino_t segv_inode;
74769 + uid_t segv_uid;
74770 + __u16 num_sprole_pws;
74771 + __u16 mode;
74772 +};
74773 +
74774 +struct gr_arg_wrapper {
74775 + struct gr_arg *arg;
74776 + __u32 version;
74777 + __u32 size;
74778 +};
74779 +
74780 +struct subject_map {
74781 + struct acl_subject_label *user;
74782 + struct acl_subject_label *kernel;
74783 + struct subject_map *prev;
74784 + struct subject_map *next;
74785 +};
74786 +
74787 +struct acl_subj_map_db {
74788 + struct subject_map **s_hash;
74789 + __u32 s_size;
74790 +};
74791 +
74792 +/* End Data Structures Section */
74793 +
74794 +/* Hash functions generated by empirical testing by Brad Spengler
74795 + Makes good use of the low bits of the inode. Generally 0-1 times
74796 + in loop for successful match. 0-3 for unsuccessful match.
74797 + Shift/add algorithm with modulus of table size and an XOR*/
74798 +
74799 +static __inline__ unsigned int
74800 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
74801 +{
74802 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
74803 +}
74804 +
74805 + static __inline__ unsigned int
74806 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
74807 +{
74808 + return ((const unsigned long)userp % sz);
74809 +}
74810 +
74811 +static __inline__ unsigned int
74812 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
74813 +{
74814 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
74815 +}
74816 +
74817 +static __inline__ unsigned int
74818 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
74819 +{
74820 + return full_name_hash((const unsigned char *)name, len) % sz;
74821 +}
74822 +
74823 +#define FOR_EACH_ROLE_START(role) \
74824 + role = role_list; \
74825 + while (role) {
74826 +
74827 +#define FOR_EACH_ROLE_END(role) \
74828 + role = role->prev; \
74829 + }
74830 +
74831 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
74832 + subj = NULL; \
74833 + iter = 0; \
74834 + while (iter < role->subj_hash_size) { \
74835 + if (subj == NULL) \
74836 + subj = role->subj_hash[iter]; \
74837 + if (subj == NULL) { \
74838 + iter++; \
74839 + continue; \
74840 + }
74841 +
74842 +#define FOR_EACH_SUBJECT_END(subj,iter) \
74843 + subj = subj->next; \
74844 + if (subj == NULL) \
74845 + iter++; \
74846 + }
74847 +
74848 +
74849 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
74850 + subj = role->hash->first; \
74851 + while (subj != NULL) {
74852 +
74853 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
74854 + subj = subj->next; \
74855 + }
74856 +
74857 +#endif
74858 +
74859 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
74860 new file mode 100644
74861 index 0000000..33ebd1f
74862 --- /dev/null
74863 +++ b/include/linux/gracl_compat.h
74864 @@ -0,0 +1,156 @@
74865 +#ifndef GR_ACL_COMPAT_H
74866 +#define GR_ACL_COMPAT_H
74867 +
74868 +#include <linux/resource.h>
74869 +#include <asm/resource.h>
74870 +
74871 +struct sprole_pw_compat {
74872 + compat_uptr_t rolename;
74873 + unsigned char salt[GR_SALT_LEN];
74874 + unsigned char sum[GR_SHA_LEN];
74875 +};
74876 +
74877 +struct gr_hash_struct_compat {
74878 + compat_uptr_t table;
74879 + compat_uptr_t nametable;
74880 + compat_uptr_t first;
74881 + __u32 table_size;
74882 + __u32 used_size;
74883 + int type;
74884 +};
74885 +
74886 +struct acl_subject_label_compat {
74887 + compat_uptr_t filename;
74888 + compat_ino_t inode;
74889 + __u32 device;
74890 + __u32 mode;
74891 + kernel_cap_t cap_mask;
74892 + kernel_cap_t cap_lower;
74893 + kernel_cap_t cap_invert_audit;
74894 +
74895 + struct compat_rlimit res[GR_NLIMITS];
74896 + __u32 resmask;
74897 +
74898 + __u8 user_trans_type;
74899 + __u8 group_trans_type;
74900 + compat_uptr_t user_transitions;
74901 + compat_uptr_t group_transitions;
74902 + __u16 user_trans_num;
74903 + __u16 group_trans_num;
74904 +
74905 + __u32 sock_families[2];
74906 + __u32 ip_proto[8];
74907 + __u32 ip_type;
74908 + compat_uptr_t ips;
74909 + __u32 ip_num;
74910 + __u32 inaddr_any_override;
74911 +
74912 + __u32 crashes;
74913 + compat_ulong_t expires;
74914 +
74915 + compat_uptr_t parent_subject;
74916 + compat_uptr_t hash;
74917 + compat_uptr_t prev;
74918 + compat_uptr_t next;
74919 +
74920 + compat_uptr_t obj_hash;
74921 + __u32 obj_hash_size;
74922 + __u16 pax_flags;
74923 +};
74924 +
74925 +struct role_allowed_ip_compat {
74926 + __u32 addr;
74927 + __u32 netmask;
74928 +
74929 + compat_uptr_t prev;
74930 + compat_uptr_t next;
74931 +};
74932 +
74933 +struct role_transition_compat {
74934 + compat_uptr_t rolename;
74935 +
74936 + compat_uptr_t prev;
74937 + compat_uptr_t next;
74938 +};
74939 +
74940 +struct acl_role_label_compat {
74941 + compat_uptr_t rolename;
74942 + uid_t uidgid;
74943 + __u16 roletype;
74944 +
74945 + __u16 auth_attempts;
74946 + compat_ulong_t expires;
74947 +
74948 + compat_uptr_t root_label;
74949 + compat_uptr_t hash;
74950 +
74951 + compat_uptr_t prev;
74952 + compat_uptr_t next;
74953 +
74954 + compat_uptr_t transitions;
74955 + compat_uptr_t allowed_ips;
74956 + compat_uptr_t domain_children;
74957 + __u16 domain_child_num;
74958 +
74959 + umode_t umask;
74960 +
74961 + compat_uptr_t subj_hash;
74962 + __u32 subj_hash_size;
74963 +};
74964 +
74965 +struct user_acl_role_db_compat {
74966 + compat_uptr_t r_table;
74967 + __u32 num_pointers;
74968 + __u32 num_roles;
74969 + __u32 num_domain_children;
74970 + __u32 num_subjects;
74971 + __u32 num_objects;
74972 +};
74973 +
74974 +struct acl_object_label_compat {
74975 + compat_uptr_t filename;
74976 + compat_ino_t inode;
74977 + __u32 device;
74978 + __u32 mode;
74979 +
74980 + compat_uptr_t nested;
74981 + compat_uptr_t globbed;
74982 +
74983 + compat_uptr_t prev;
74984 + compat_uptr_t next;
74985 +};
74986 +
74987 +struct acl_ip_label_compat {
74988 + compat_uptr_t iface;
74989 + __u32 addr;
74990 + __u32 netmask;
74991 + __u16 low, high;
74992 + __u8 mode;
74993 + __u32 type;
74994 + __u32 proto[8];
74995 +
74996 + compat_uptr_t prev;
74997 + compat_uptr_t next;
74998 +};
74999 +
75000 +struct gr_arg_compat {
75001 + struct user_acl_role_db_compat role_db;
75002 + unsigned char pw[GR_PW_LEN];
75003 + unsigned char salt[GR_SALT_LEN];
75004 + unsigned char sum[GR_SHA_LEN];
75005 + unsigned char sp_role[GR_SPROLE_LEN];
75006 + compat_uptr_t sprole_pws;
75007 + __u32 segv_device;
75008 + compat_ino_t segv_inode;
75009 + uid_t segv_uid;
75010 + __u16 num_sprole_pws;
75011 + __u16 mode;
75012 +};
75013 +
75014 +struct gr_arg_wrapper_compat {
75015 + compat_uptr_t arg;
75016 + __u32 version;
75017 + __u32 size;
75018 +};
75019 +
75020 +#endif
75021 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
75022 new file mode 100644
75023 index 0000000..323ecf2
75024 --- /dev/null
75025 +++ b/include/linux/gralloc.h
75026 @@ -0,0 +1,9 @@
75027 +#ifndef __GRALLOC_H
75028 +#define __GRALLOC_H
75029 +
75030 +void acl_free_all(void);
75031 +int acl_alloc_stack_init(unsigned long size);
75032 +void *acl_alloc(unsigned long len);
75033 +void *acl_alloc_num(unsigned long num, unsigned long len);
75034 +
75035 +#endif
75036 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
75037 new file mode 100644
75038 index 0000000..be66033
75039 --- /dev/null
75040 +++ b/include/linux/grdefs.h
75041 @@ -0,0 +1,140 @@
75042 +#ifndef GRDEFS_H
75043 +#define GRDEFS_H
75044 +
75045 +/* Begin grsecurity status declarations */
75046 +
75047 +enum {
75048 + GR_READY = 0x01,
75049 + GR_STATUS_INIT = 0x00 // disabled state
75050 +};
75051 +
75052 +/* Begin ACL declarations */
75053 +
75054 +/* Role flags */
75055 +
75056 +enum {
75057 + GR_ROLE_USER = 0x0001,
75058 + GR_ROLE_GROUP = 0x0002,
75059 + GR_ROLE_DEFAULT = 0x0004,
75060 + GR_ROLE_SPECIAL = 0x0008,
75061 + GR_ROLE_AUTH = 0x0010,
75062 + GR_ROLE_NOPW = 0x0020,
75063 + GR_ROLE_GOD = 0x0040,
75064 + GR_ROLE_LEARN = 0x0080,
75065 + GR_ROLE_TPE = 0x0100,
75066 + GR_ROLE_DOMAIN = 0x0200,
75067 + GR_ROLE_PAM = 0x0400,
75068 + GR_ROLE_PERSIST = 0x0800
75069 +};
75070 +
75071 +/* ACL Subject and Object mode flags */
75072 +enum {
75073 + GR_DELETED = 0x80000000
75074 +};
75075 +
75076 +/* ACL Object-only mode flags */
75077 +enum {
75078 + GR_READ = 0x00000001,
75079 + GR_APPEND = 0x00000002,
75080 + GR_WRITE = 0x00000004,
75081 + GR_EXEC = 0x00000008,
75082 + GR_FIND = 0x00000010,
75083 + GR_INHERIT = 0x00000020,
75084 + GR_SETID = 0x00000040,
75085 + GR_CREATE = 0x00000080,
75086 + GR_DELETE = 0x00000100,
75087 + GR_LINK = 0x00000200,
75088 + GR_AUDIT_READ = 0x00000400,
75089 + GR_AUDIT_APPEND = 0x00000800,
75090 + GR_AUDIT_WRITE = 0x00001000,
75091 + GR_AUDIT_EXEC = 0x00002000,
75092 + GR_AUDIT_FIND = 0x00004000,
75093 + GR_AUDIT_INHERIT= 0x00008000,
75094 + GR_AUDIT_SETID = 0x00010000,
75095 + GR_AUDIT_CREATE = 0x00020000,
75096 + GR_AUDIT_DELETE = 0x00040000,
75097 + GR_AUDIT_LINK = 0x00080000,
75098 + GR_PTRACERD = 0x00100000,
75099 + GR_NOPTRACE = 0x00200000,
75100 + GR_SUPPRESS = 0x00400000,
75101 + GR_NOLEARN = 0x00800000,
75102 + GR_INIT_TRANSFER= 0x01000000
75103 +};
75104 +
75105 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
75106 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
75107 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
75108 +
75109 +/* ACL subject-only mode flags */
75110 +enum {
75111 + GR_KILL = 0x00000001,
75112 + GR_VIEW = 0x00000002,
75113 + GR_PROTECTED = 0x00000004,
75114 + GR_LEARN = 0x00000008,
75115 + GR_OVERRIDE = 0x00000010,
75116 + /* just a placeholder, this mode is only used in userspace */
75117 + GR_DUMMY = 0x00000020,
75118 + GR_PROTSHM = 0x00000040,
75119 + GR_KILLPROC = 0x00000080,
75120 + GR_KILLIPPROC = 0x00000100,
75121 + /* just a placeholder, this mode is only used in userspace */
75122 + GR_NOTROJAN = 0x00000200,
75123 + GR_PROTPROCFD = 0x00000400,
75124 + GR_PROCACCT = 0x00000800,
75125 + GR_RELAXPTRACE = 0x00001000,
75126 + //GR_NESTED = 0x00002000,
75127 + GR_INHERITLEARN = 0x00004000,
75128 + GR_PROCFIND = 0x00008000,
75129 + GR_POVERRIDE = 0x00010000,
75130 + GR_KERNELAUTH = 0x00020000,
75131 + GR_ATSECURE = 0x00040000,
75132 + GR_SHMEXEC = 0x00080000
75133 +};
75134 +
75135 +enum {
75136 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
75137 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
75138 + GR_PAX_ENABLE_MPROTECT = 0x0004,
75139 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
75140 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
75141 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
75142 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
75143 + GR_PAX_DISABLE_MPROTECT = 0x0400,
75144 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
75145 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
75146 +};
75147 +
75148 +enum {
75149 + GR_ID_USER = 0x01,
75150 + GR_ID_GROUP = 0x02,
75151 +};
75152 +
75153 +enum {
75154 + GR_ID_ALLOW = 0x01,
75155 + GR_ID_DENY = 0x02,
75156 +};
75157 +
75158 +#define GR_CRASH_RES 31
75159 +#define GR_UIDTABLE_MAX 500
75160 +
75161 +/* begin resource learning section */
75162 +enum {
75163 + GR_RLIM_CPU_BUMP = 60,
75164 + GR_RLIM_FSIZE_BUMP = 50000,
75165 + GR_RLIM_DATA_BUMP = 10000,
75166 + GR_RLIM_STACK_BUMP = 1000,
75167 + GR_RLIM_CORE_BUMP = 10000,
75168 + GR_RLIM_RSS_BUMP = 500000,
75169 + GR_RLIM_NPROC_BUMP = 1,
75170 + GR_RLIM_NOFILE_BUMP = 5,
75171 + GR_RLIM_MEMLOCK_BUMP = 50000,
75172 + GR_RLIM_AS_BUMP = 500000,
75173 + GR_RLIM_LOCKS_BUMP = 2,
75174 + GR_RLIM_SIGPENDING_BUMP = 5,
75175 + GR_RLIM_MSGQUEUE_BUMP = 10000,
75176 + GR_RLIM_NICE_BUMP = 1,
75177 + GR_RLIM_RTPRIO_BUMP = 1,
75178 + GR_RLIM_RTTIME_BUMP = 1000000
75179 +};
75180 +
75181 +#endif
75182 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
75183 new file mode 100644
75184 index 0000000..e337683
75185 --- /dev/null
75186 +++ b/include/linux/grinternal.h
75187 @@ -0,0 +1,229 @@
75188 +#ifndef __GRINTERNAL_H
75189 +#define __GRINTERNAL_H
75190 +
75191 +#ifdef CONFIG_GRKERNSEC
75192 +
75193 +#include <linux/fs.h>
75194 +#include <linux/mnt_namespace.h>
75195 +#include <linux/nsproxy.h>
75196 +#include <linux/gracl.h>
75197 +#include <linux/grdefs.h>
75198 +#include <linux/grmsg.h>
75199 +
75200 +void gr_add_learn_entry(const char *fmt, ...)
75201 + __attribute__ ((format (printf, 1, 2)));
75202 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
75203 + const struct vfsmount *mnt);
75204 +__u32 gr_check_create(const struct dentry *new_dentry,
75205 + const struct dentry *parent,
75206 + const struct vfsmount *mnt, const __u32 mode);
75207 +int gr_check_protected_task(const struct task_struct *task);
75208 +__u32 to_gr_audit(const __u32 reqmode);
75209 +int gr_set_acls(const int type);
75210 +int gr_apply_subject_to_task(struct task_struct *task);
75211 +int gr_acl_is_enabled(void);
75212 +char gr_roletype_to_char(void);
75213 +
75214 +void gr_handle_alertkill(struct task_struct *task);
75215 +char *gr_to_filename(const struct dentry *dentry,
75216 + const struct vfsmount *mnt);
75217 +char *gr_to_filename1(const struct dentry *dentry,
75218 + const struct vfsmount *mnt);
75219 +char *gr_to_filename2(const struct dentry *dentry,
75220 + const struct vfsmount *mnt);
75221 +char *gr_to_filename3(const struct dentry *dentry,
75222 + const struct vfsmount *mnt);
75223 +
75224 +extern int grsec_enable_ptrace_readexec;
75225 +extern int grsec_enable_harden_ptrace;
75226 +extern int grsec_enable_link;
75227 +extern int grsec_enable_fifo;
75228 +extern int grsec_enable_execve;
75229 +extern int grsec_enable_shm;
75230 +extern int grsec_enable_execlog;
75231 +extern int grsec_enable_signal;
75232 +extern int grsec_enable_audit_ptrace;
75233 +extern int grsec_enable_forkfail;
75234 +extern int grsec_enable_time;
75235 +extern int grsec_enable_rofs;
75236 +extern int grsec_deny_new_usb;
75237 +extern int grsec_enable_chroot_shmat;
75238 +extern int grsec_enable_chroot_mount;
75239 +extern int grsec_enable_chroot_double;
75240 +extern int grsec_enable_chroot_pivot;
75241 +extern int grsec_enable_chroot_chdir;
75242 +extern int grsec_enable_chroot_chmod;
75243 +extern int grsec_enable_chroot_mknod;
75244 +extern int grsec_enable_chroot_fchdir;
75245 +extern int grsec_enable_chroot_nice;
75246 +extern int grsec_enable_chroot_execlog;
75247 +extern int grsec_enable_chroot_caps;
75248 +extern int grsec_enable_chroot_sysctl;
75249 +extern int grsec_enable_chroot_unix;
75250 +extern int grsec_enable_symlinkown;
75251 +extern kgid_t grsec_symlinkown_gid;
75252 +extern int grsec_enable_tpe;
75253 +extern kgid_t grsec_tpe_gid;
75254 +extern int grsec_enable_tpe_all;
75255 +extern int grsec_enable_tpe_invert;
75256 +extern int grsec_enable_socket_all;
75257 +extern kgid_t grsec_socket_all_gid;
75258 +extern int grsec_enable_socket_client;
75259 +extern kgid_t grsec_socket_client_gid;
75260 +extern int grsec_enable_socket_server;
75261 +extern kgid_t grsec_socket_server_gid;
75262 +extern kgid_t grsec_audit_gid;
75263 +extern int grsec_enable_group;
75264 +extern int grsec_enable_log_rwxmaps;
75265 +extern int grsec_enable_mount;
75266 +extern int grsec_enable_chdir;
75267 +extern int grsec_resource_logging;
75268 +extern int grsec_enable_blackhole;
75269 +extern int grsec_lastack_retries;
75270 +extern int grsec_enable_brute;
75271 +extern int grsec_lock;
75272 +
75273 +extern spinlock_t grsec_alert_lock;
75274 +extern unsigned long grsec_alert_wtime;
75275 +extern unsigned long grsec_alert_fyet;
75276 +
75277 +extern spinlock_t grsec_audit_lock;
75278 +
75279 +extern rwlock_t grsec_exec_file_lock;
75280 +
75281 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
75282 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
75283 + (tsk)->exec_file->f_path.mnt) : "/")
75284 +
75285 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
75286 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
75287 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75288 +
75289 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
75290 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
75291 + (tsk)->exec_file->f_path.mnt) : "/")
75292 +
75293 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
75294 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
75295 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75296 +
75297 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
75298 +
75299 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
75300 +
75301 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
75302 +{
75303 + if (file1 && file2) {
75304 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
75305 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
75306 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
75307 + return true;
75308 + }
75309 +
75310 + return false;
75311 +}
75312 +
75313 +#define GR_CHROOT_CAPS {{ \
75314 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
75315 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
75316 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
75317 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
75318 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
75319 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
75320 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
75321 +
75322 +#define security_learn(normal_msg,args...) \
75323 +({ \
75324 + read_lock(&grsec_exec_file_lock); \
75325 + gr_add_learn_entry(normal_msg "\n", ## args); \
75326 + read_unlock(&grsec_exec_file_lock); \
75327 +})
75328 +
75329 +enum {
75330 + GR_DO_AUDIT,
75331 + GR_DONT_AUDIT,
75332 + /* used for non-audit messages that we shouldn't kill the task on */
75333 + GR_DONT_AUDIT_GOOD
75334 +};
75335 +
75336 +enum {
75337 + GR_TTYSNIFF,
75338 + GR_RBAC,
75339 + GR_RBAC_STR,
75340 + GR_STR_RBAC,
75341 + GR_RBAC_MODE2,
75342 + GR_RBAC_MODE3,
75343 + GR_FILENAME,
75344 + GR_SYSCTL_HIDDEN,
75345 + GR_NOARGS,
75346 + GR_ONE_INT,
75347 + GR_ONE_INT_TWO_STR,
75348 + GR_ONE_STR,
75349 + GR_STR_INT,
75350 + GR_TWO_STR_INT,
75351 + GR_TWO_INT,
75352 + GR_TWO_U64,
75353 + GR_THREE_INT,
75354 + GR_FIVE_INT_TWO_STR,
75355 + GR_TWO_STR,
75356 + GR_THREE_STR,
75357 + GR_FOUR_STR,
75358 + GR_STR_FILENAME,
75359 + GR_FILENAME_STR,
75360 + GR_FILENAME_TWO_INT,
75361 + GR_FILENAME_TWO_INT_STR,
75362 + GR_TEXTREL,
75363 + GR_PTRACE,
75364 + GR_RESOURCE,
75365 + GR_CAP,
75366 + GR_SIG,
75367 + GR_SIG2,
75368 + GR_CRASH1,
75369 + GR_CRASH2,
75370 + GR_PSACCT,
75371 + GR_RWXMAP,
75372 + GR_RWXMAPVMA
75373 +};
75374 +
75375 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
75376 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
75377 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
75378 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
75379 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
75380 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
75381 +#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)
75382 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
75383 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
75384 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
75385 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
75386 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
75387 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
75388 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
75389 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
75390 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
75391 +#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)
75392 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
75393 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
75394 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
75395 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
75396 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
75397 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
75398 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
75399 +#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)
75400 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
75401 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
75402 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
75403 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
75404 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
75405 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
75406 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
75407 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
75408 +#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)
75409 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
75410 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
75411 +
75412 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
75413 +
75414 +#endif
75415 +
75416 +#endif
75417 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
75418 new file mode 100644
75419 index 0000000..a4396b5
75420 --- /dev/null
75421 +++ b/include/linux/grmsg.h
75422 @@ -0,0 +1,113 @@
75423 +#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"
75424 +#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"
75425 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
75426 +#define GR_STOPMOD_MSG "denied modification of module state by "
75427 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
75428 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
75429 +#define GR_IOPERM_MSG "denied use of ioperm() by "
75430 +#define GR_IOPL_MSG "denied use of iopl() by "
75431 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
75432 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
75433 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
75434 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
75435 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75436 +#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"
75437 +#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"
75438 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75439 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75440 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75441 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75442 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75443 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75444 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75445 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75446 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75447 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75448 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75449 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75450 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75451 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75452 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75453 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75454 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75455 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75456 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75457 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75458 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75459 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75460 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75461 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75462 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75463 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75464 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75465 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75466 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75467 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75468 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75469 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75470 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75471 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75472 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75473 +#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"
75474 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75475 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75476 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75477 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75478 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75479 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75480 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75481 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75482 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75483 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75484 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75485 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75486 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75487 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75488 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75489 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75490 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75491 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75492 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75493 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75494 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75495 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75496 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75497 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75498 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75499 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75500 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75501 +#define GR_TIME_MSG "time set by "
75502 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75503 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75504 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75505 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75506 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75507 +#define GR_BIND_MSG "denied bind() by "
75508 +#define GR_CONNECT_MSG "denied connect() by "
75509 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75510 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75511 +#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"
75512 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75513 +#define GR_CAP_ACL_MSG "use of %s denied for "
75514 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75515 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75516 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75517 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75518 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75519 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75520 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75521 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75522 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75523 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75524 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75525 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75526 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75527 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75528 +#define GR_VM86_MSG "denied use of vm86 by "
75529 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75530 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75531 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75532 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75533 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75534 +#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 "
75535 +#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 "
75536 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75537 new file mode 100644
75538 index 0000000..d6f5a21
75539 --- /dev/null
75540 +++ b/include/linux/grsecurity.h
75541 @@ -0,0 +1,244 @@
75542 +#ifndef GR_SECURITY_H
75543 +#define GR_SECURITY_H
75544 +#include <linux/fs.h>
75545 +#include <linux/fs_struct.h>
75546 +#include <linux/binfmts.h>
75547 +#include <linux/gracl.h>
75548 +
75549 +/* notify of brain-dead configs */
75550 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75551 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75552 +#endif
75553 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75554 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75555 +#endif
75556 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75557 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75558 +#endif
75559 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75560 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75561 +#endif
75562 +
75563 +int gr_handle_new_usb(void);
75564 +
75565 +void gr_handle_brute_attach(unsigned long mm_flags);
75566 +void gr_handle_brute_check(void);
75567 +void gr_handle_kernel_exploit(void);
75568 +
75569 +char gr_roletype_to_char(void);
75570 +
75571 +int gr_acl_enable_at_secure(void);
75572 +
75573 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75574 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75575 +
75576 +void gr_del_task_from_ip_table(struct task_struct *p);
75577 +
75578 +int gr_pid_is_chrooted(struct task_struct *p);
75579 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75580 +int gr_handle_chroot_nice(void);
75581 +int gr_handle_chroot_sysctl(const int op);
75582 +int gr_handle_chroot_setpriority(struct task_struct *p,
75583 + const int niceval);
75584 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75585 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75586 + const struct vfsmount *mnt);
75587 +void gr_handle_chroot_chdir(const struct path *path);
75588 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75589 + const struct vfsmount *mnt, const int mode);
75590 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75591 + const struct vfsmount *mnt, const int mode);
75592 +int gr_handle_chroot_mount(const struct dentry *dentry,
75593 + const struct vfsmount *mnt,
75594 + const char *dev_name);
75595 +int gr_handle_chroot_pivot(void);
75596 +int gr_handle_chroot_unix(const pid_t pid);
75597 +
75598 +int gr_handle_rawio(const struct inode *inode);
75599 +
75600 +void gr_handle_ioperm(void);
75601 +void gr_handle_iopl(void);
75602 +
75603 +umode_t gr_acl_umask(void);
75604 +
75605 +int gr_tpe_allow(const struct file *file);
75606 +
75607 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75608 +void gr_clear_chroot_entries(struct task_struct *task);
75609 +
75610 +void gr_log_forkfail(const int retval);
75611 +void gr_log_timechange(void);
75612 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75613 +void gr_log_chdir(const struct dentry *dentry,
75614 + const struct vfsmount *mnt);
75615 +void gr_log_chroot_exec(const struct dentry *dentry,
75616 + const struct vfsmount *mnt);
75617 +void gr_log_remount(const char *devname, const int retval);
75618 +void gr_log_unmount(const char *devname, const int retval);
75619 +void gr_log_mount(const char *from, const char *to, const int retval);
75620 +void gr_log_textrel(struct vm_area_struct *vma);
75621 +void gr_log_ptgnustack(struct file *file);
75622 +void gr_log_rwxmmap(struct file *file);
75623 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75624 +
75625 +int gr_handle_follow_link(const struct inode *parent,
75626 + const struct inode *inode,
75627 + const struct dentry *dentry,
75628 + const struct vfsmount *mnt);
75629 +int gr_handle_fifo(const struct dentry *dentry,
75630 + const struct vfsmount *mnt,
75631 + const struct dentry *dir, const int flag,
75632 + const int acc_mode);
75633 +int gr_handle_hardlink(const struct dentry *dentry,
75634 + const struct vfsmount *mnt,
75635 + struct inode *inode,
75636 + const int mode, const struct filename *to);
75637 +
75638 +int gr_is_capable(const int cap);
75639 +int gr_is_capable_nolog(const int cap);
75640 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75641 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75642 +
75643 +void gr_copy_label(struct task_struct *tsk);
75644 +void gr_handle_crash(struct task_struct *task, const int sig);
75645 +int gr_handle_signal(const struct task_struct *p, const int sig);
75646 +int gr_check_crash_uid(const kuid_t uid);
75647 +int gr_check_protected_task(const struct task_struct *task);
75648 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75649 +int gr_acl_handle_mmap(const struct file *file,
75650 + const unsigned long prot);
75651 +int gr_acl_handle_mprotect(const struct file *file,
75652 + const unsigned long prot);
75653 +int gr_check_hidden_task(const struct task_struct *tsk);
75654 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75655 + const struct vfsmount *mnt);
75656 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75657 + const struct vfsmount *mnt);
75658 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75659 + const struct vfsmount *mnt, const int fmode);
75660 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75661 + const struct vfsmount *mnt, umode_t *mode);
75662 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75663 + const struct vfsmount *mnt);
75664 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75665 + const struct vfsmount *mnt);
75666 +int gr_handle_ptrace(struct task_struct *task, const long request);
75667 +int gr_handle_proc_ptrace(struct task_struct *task);
75668 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75669 + const struct vfsmount *mnt);
75670 +int gr_check_crash_exec(const struct file *filp);
75671 +int gr_acl_is_enabled(void);
75672 +void gr_set_kernel_label(struct task_struct *task);
75673 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75674 + const kgid_t gid);
75675 +int gr_set_proc_label(const struct dentry *dentry,
75676 + const struct vfsmount *mnt,
75677 + const int unsafe_flags);
75678 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
75679 + const struct vfsmount *mnt);
75680 +__u32 gr_acl_handle_open(const struct dentry *dentry,
75681 + const struct vfsmount *mnt, int acc_mode);
75682 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
75683 + const struct dentry *p_dentry,
75684 + const struct vfsmount *p_mnt,
75685 + int open_flags, int acc_mode, const int imode);
75686 +void gr_handle_create(const struct dentry *dentry,
75687 + const struct vfsmount *mnt);
75688 +void gr_handle_proc_create(const struct dentry *dentry,
75689 + const struct inode *inode);
75690 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
75691 + const struct dentry *parent_dentry,
75692 + const struct vfsmount *parent_mnt,
75693 + const int mode);
75694 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
75695 + const struct dentry *parent_dentry,
75696 + const struct vfsmount *parent_mnt);
75697 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
75698 + const struct vfsmount *mnt);
75699 +void gr_handle_delete(const ino_t ino, const dev_t dev);
75700 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
75701 + const struct vfsmount *mnt);
75702 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
75703 + const struct dentry *parent_dentry,
75704 + const struct vfsmount *parent_mnt,
75705 + const struct filename *from);
75706 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
75707 + const struct dentry *parent_dentry,
75708 + const struct vfsmount *parent_mnt,
75709 + const struct dentry *old_dentry,
75710 + const struct vfsmount *old_mnt, const struct filename *to);
75711 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
75712 +int gr_acl_handle_rename(struct dentry *new_dentry,
75713 + struct dentry *parent_dentry,
75714 + const struct vfsmount *parent_mnt,
75715 + struct dentry *old_dentry,
75716 + struct inode *old_parent_inode,
75717 + struct vfsmount *old_mnt, const struct filename *newname);
75718 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
75719 + struct dentry *old_dentry,
75720 + struct dentry *new_dentry,
75721 + struct vfsmount *mnt, const __u8 replace);
75722 +__u32 gr_check_link(const struct dentry *new_dentry,
75723 + const struct dentry *parent_dentry,
75724 + const struct vfsmount *parent_mnt,
75725 + const struct dentry *old_dentry,
75726 + const struct vfsmount *old_mnt);
75727 +int gr_acl_handle_filldir(const struct file *file, const char *name,
75728 + const unsigned int namelen, const ino_t ino);
75729 +
75730 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
75731 + const struct vfsmount *mnt);
75732 +void gr_acl_handle_exit(void);
75733 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
75734 +int gr_acl_handle_procpidmem(const struct task_struct *task);
75735 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
75736 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
75737 +void gr_audit_ptrace(struct task_struct *task);
75738 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
75739 +void gr_put_exec_file(struct task_struct *task);
75740 +
75741 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
75742 +
75743 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
75744 +extern void gr_learn_resource(const struct task_struct *task, const int res,
75745 + const unsigned long wanted, const int gt);
75746 +#else
75747 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
75748 + const unsigned long wanted, const int gt)
75749 +{
75750 +}
75751 +#endif
75752 +
75753 +#ifdef CONFIG_GRKERNSEC_RESLOG
75754 +extern void gr_log_resource(const struct task_struct *task, const int res,
75755 + const unsigned long wanted, const int gt);
75756 +#else
75757 +static inline void gr_log_resource(const struct task_struct *task, const int res,
75758 + const unsigned long wanted, const int gt)
75759 +{
75760 +}
75761 +#endif
75762 +
75763 +#ifdef CONFIG_GRKERNSEC
75764 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
75765 +void gr_handle_vm86(void);
75766 +void gr_handle_mem_readwrite(u64 from, u64 to);
75767 +
75768 +void gr_log_badprocpid(const char *entry);
75769 +
75770 +extern int grsec_enable_dmesg;
75771 +extern int grsec_disable_privio;
75772 +
75773 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75774 +extern kgid_t grsec_proc_gid;
75775 +#endif
75776 +
75777 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
75778 +extern int grsec_enable_chroot_findtask;
75779 +#endif
75780 +#ifdef CONFIG_GRKERNSEC_SETXID
75781 +extern int grsec_enable_setxid;
75782 +#endif
75783 +#endif
75784 +
75785 +#endif
75786 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
75787 new file mode 100644
75788 index 0000000..e7ffaaf
75789 --- /dev/null
75790 +++ b/include/linux/grsock.h
75791 @@ -0,0 +1,19 @@
75792 +#ifndef __GRSOCK_H
75793 +#define __GRSOCK_H
75794 +
75795 +extern void gr_attach_curr_ip(const struct sock *sk);
75796 +extern int gr_handle_sock_all(const int family, const int type,
75797 + const int protocol);
75798 +extern int gr_handle_sock_server(const struct sockaddr *sck);
75799 +extern int gr_handle_sock_server_other(const struct sock *sck);
75800 +extern int gr_handle_sock_client(const struct sockaddr *sck);
75801 +extern int gr_search_connect(struct socket * sock,
75802 + struct sockaddr_in * addr);
75803 +extern int gr_search_bind(struct socket * sock,
75804 + struct sockaddr_in * addr);
75805 +extern int gr_search_listen(struct socket * sock);
75806 +extern int gr_search_accept(struct socket * sock);
75807 +extern int gr_search_socket(const int domain, const int type,
75808 + const int protocol);
75809 +
75810 +#endif
75811 diff --git a/include/linux/hid.h b/include/linux/hid.h
75812 index 0c48991..76e41d8 100644
75813 --- a/include/linux/hid.h
75814 +++ b/include/linux/hid.h
75815 @@ -393,10 +393,12 @@ struct hid_report {
75816 struct hid_device *device; /* associated device */
75817 };
75818
75819 +#define HID_MAX_IDS 256
75820 +
75821 struct hid_report_enum {
75822 unsigned numbered;
75823 struct list_head report_list;
75824 - struct hid_report *report_id_hash[256];
75825 + struct hid_report *report_id_hash[HID_MAX_IDS];
75826 };
75827
75828 #define HID_REPORT_TYPES 3
75829 @@ -747,6 +749,10 @@ void hid_output_report(struct hid_report *report, __u8 *data);
75830 struct hid_device *hid_allocate_device(void);
75831 struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
75832 int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
75833 +struct hid_report *hid_validate_report(struct hid_device *hid,
75834 + unsigned int type, unsigned int id,
75835 + unsigned int fields,
75836 + unsigned int report_counts);
75837 int hid_open_report(struct hid_device *device);
75838 int hid_check_keys_pressed(struct hid_device *hid);
75839 int hid_connect(struct hid_device *hid, unsigned int connect_mask);
75840 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
75841 index 7fb31da..08b5114 100644
75842 --- a/include/linux/highmem.h
75843 +++ b/include/linux/highmem.h
75844 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
75845 kunmap_atomic(kaddr);
75846 }
75847
75848 +static inline void sanitize_highpage(struct page *page)
75849 +{
75850 + void *kaddr;
75851 + unsigned long flags;
75852 +
75853 + local_irq_save(flags);
75854 + kaddr = kmap_atomic(page);
75855 + clear_page(kaddr);
75856 + kunmap_atomic(kaddr);
75857 + local_irq_restore(flags);
75858 +}
75859 +
75860 static inline void zero_user_segments(struct page *page,
75861 unsigned start1, unsigned end1,
75862 unsigned start2, unsigned end2)
75863 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
75864 index 1c7b89a..7f52502 100644
75865 --- a/include/linux/hwmon-sysfs.h
75866 +++ b/include/linux/hwmon-sysfs.h
75867 @@ -25,7 +25,8 @@
75868 struct sensor_device_attribute{
75869 struct device_attribute dev_attr;
75870 int index;
75871 -};
75872 +} __do_const;
75873 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
75874 #define to_sensor_dev_attr(_dev_attr) \
75875 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
75876
75877 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
75878 struct device_attribute dev_attr;
75879 u8 index;
75880 u8 nr;
75881 -};
75882 +} __do_const;
75883 #define to_sensor_dev_attr_2(_dev_attr) \
75884 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
75885
75886 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
75887 index e988fa9..ff9f17e 100644
75888 --- a/include/linux/i2c.h
75889 +++ b/include/linux/i2c.h
75890 @@ -366,6 +366,7 @@ struct i2c_algorithm {
75891 /* To determine what the adapter supports */
75892 u32 (*functionality) (struct i2c_adapter *);
75893 };
75894 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
75895
75896 /**
75897 * struct i2c_bus_recovery_info - I2C bus recovery information
75898 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
75899 index d23c3c2..eb63c81 100644
75900 --- a/include/linux/i2o.h
75901 +++ b/include/linux/i2o.h
75902 @@ -565,7 +565,7 @@ struct i2o_controller {
75903 struct i2o_device *exec; /* Executive */
75904 #if BITS_PER_LONG == 64
75905 spinlock_t context_list_lock; /* lock for context_list */
75906 - atomic_t context_list_counter; /* needed for unique contexts */
75907 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
75908 struct list_head context_list; /* list of context id's
75909 and pointers */
75910 #endif
75911 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
75912 index aff7ad8..3942bbd 100644
75913 --- a/include/linux/if_pppox.h
75914 +++ b/include/linux/if_pppox.h
75915 @@ -76,7 +76,7 @@ struct pppox_proto {
75916 int (*ioctl)(struct socket *sock, unsigned int cmd,
75917 unsigned long arg);
75918 struct module *owner;
75919 -};
75920 +} __do_const;
75921
75922 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
75923 extern void unregister_pppox_proto(int proto_num);
75924 diff --git a/include/linux/init.h b/include/linux/init.h
75925 index 8618147..0821126 100644
75926 --- a/include/linux/init.h
75927 +++ b/include/linux/init.h
75928 @@ -39,9 +39,36 @@
75929 * Also note, that this data cannot be "const".
75930 */
75931
75932 +#ifdef MODULE
75933 +#define add_init_latent_entropy
75934 +#define add_devinit_latent_entropy
75935 +#define add_cpuinit_latent_entropy
75936 +#define add_meminit_latent_entropy
75937 +#else
75938 +#define add_init_latent_entropy __latent_entropy
75939 +
75940 +#ifdef CONFIG_HOTPLUG
75941 +#define add_devinit_latent_entropy
75942 +#else
75943 +#define add_devinit_latent_entropy __latent_entropy
75944 +#endif
75945 +
75946 +#ifdef CONFIG_HOTPLUG_CPU
75947 +#define add_cpuinit_latent_entropy
75948 +#else
75949 +#define add_cpuinit_latent_entropy __latent_entropy
75950 +#endif
75951 +
75952 +#ifdef CONFIG_MEMORY_HOTPLUG
75953 +#define add_meminit_latent_entropy
75954 +#else
75955 +#define add_meminit_latent_entropy __latent_entropy
75956 +#endif
75957 +#endif
75958 +
75959 /* These are for everybody (although not all archs will actually
75960 discard it in modules) */
75961 -#define __init __section(.init.text) __cold notrace
75962 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
75963 #define __initdata __section(.init.data)
75964 #define __initconst __constsection(.init.rodata)
75965 #define __exitdata __section(.exit.data)
75966 @@ -94,7 +121,7 @@
75967 #define __exit __section(.exit.text) __exitused __cold notrace
75968
75969 /* Used for HOTPLUG_CPU */
75970 -#define __cpuinit __section(.cpuinit.text) __cold notrace
75971 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
75972 #define __cpuinitdata __section(.cpuinit.data)
75973 #define __cpuinitconst __constsection(.cpuinit.rodata)
75974 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
75975 @@ -102,7 +129,7 @@
75976 #define __cpuexitconst __constsection(.cpuexit.rodata)
75977
75978 /* Used for MEMORY_HOTPLUG */
75979 -#define __meminit __section(.meminit.text) __cold notrace
75980 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
75981 #define __meminitdata __section(.meminit.data)
75982 #define __meminitconst __constsection(.meminit.rodata)
75983 #define __memexit __section(.memexit.text) __exitused __cold notrace
75984 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
75985 index 5cd0f09..c9f67cc 100644
75986 --- a/include/linux/init_task.h
75987 +++ b/include/linux/init_task.h
75988 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
75989
75990 #define INIT_TASK_COMM "swapper"
75991
75992 +#ifdef CONFIG_X86
75993 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
75994 +#else
75995 +#define INIT_TASK_THREAD_INFO
75996 +#endif
75997 +
75998 /*
75999 * INIT_TASK is used to set up the first task table, touch at
76000 * your own risk!. Base=0, limit=0x1fffff (=2MB)
76001 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
76002 RCU_POINTER_INITIALIZER(cred, &init_cred), \
76003 .comm = INIT_TASK_COMM, \
76004 .thread = INIT_THREAD, \
76005 + INIT_TASK_THREAD_INFO \
76006 .fs = &init_fs, \
76007 .files = &init_files, \
76008 .signal = &init_signals, \
76009 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
76010 index 5fa5afe..ac55b25 100644
76011 --- a/include/linux/interrupt.h
76012 +++ b/include/linux/interrupt.h
76013 @@ -430,7 +430,7 @@ enum
76014 /* map softirq index to softirq name. update 'softirq_to_name' in
76015 * kernel/softirq.c when adding a new softirq.
76016 */
76017 -extern char *softirq_to_name[NR_SOFTIRQS];
76018 +extern const char * const softirq_to_name[NR_SOFTIRQS];
76019
76020 /* softirq mask and active fields moved to irq_cpustat_t in
76021 * asm/hardirq.h to get better cache usage. KAO
76022 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
76023
76024 struct softirq_action
76025 {
76026 - void (*action)(struct softirq_action *);
76027 -};
76028 + void (*action)(void);
76029 +} __no_const;
76030
76031 asmlinkage void do_softirq(void);
76032 asmlinkage void __do_softirq(void);
76033 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
76034 +extern void open_softirq(int nr, void (*action)(void));
76035 extern void softirq_init(void);
76036 extern void __raise_softirq_irqoff(unsigned int nr);
76037
76038 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
76039 index 3aeb730..2177f39 100644
76040 --- a/include/linux/iommu.h
76041 +++ b/include/linux/iommu.h
76042 @@ -113,7 +113,7 @@ struct iommu_ops {
76043 u32 (*domain_get_windows)(struct iommu_domain *domain);
76044
76045 unsigned long pgsize_bitmap;
76046 -};
76047 +} __do_const;
76048
76049 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
76050 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
76051 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
76052 index 89b7c24..382af74 100644
76053 --- a/include/linux/ioport.h
76054 +++ b/include/linux/ioport.h
76055 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
76056 int adjust_resource(struct resource *res, resource_size_t start,
76057 resource_size_t size);
76058 resource_size_t resource_alignment(struct resource *res);
76059 -static inline resource_size_t resource_size(const struct resource *res)
76060 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
76061 {
76062 return res->end - res->start + 1;
76063 }
76064 diff --git a/include/linux/irq.h b/include/linux/irq.h
76065 index bc4e066..50468a9 100644
76066 --- a/include/linux/irq.h
76067 +++ b/include/linux/irq.h
76068 @@ -328,7 +328,8 @@ struct irq_chip {
76069 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
76070
76071 unsigned long flags;
76072 -};
76073 +} __do_const;
76074 +typedef struct irq_chip __no_const irq_chip_no_const;
76075
76076 /*
76077 * irq_chip specific flags
76078 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
76079 index 3e203eb..3fe68d0 100644
76080 --- a/include/linux/irqchip/arm-gic.h
76081 +++ b/include/linux/irqchip/arm-gic.h
76082 @@ -59,9 +59,11 @@
76083
76084 #ifndef __ASSEMBLY__
76085
76086 +#include <linux/irq.h>
76087 +
76088 struct device_node;
76089
76090 -extern struct irq_chip gic_arch_extn;
76091 +extern irq_chip_no_const gic_arch_extn;
76092
76093 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
76094 u32 offset, struct device_node *);
76095 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
76096 index 6883e19..e854fcb 100644
76097 --- a/include/linux/kallsyms.h
76098 +++ b/include/linux/kallsyms.h
76099 @@ -15,7 +15,8 @@
76100
76101 struct module;
76102
76103 -#ifdef CONFIG_KALLSYMS
76104 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
76105 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76106 /* Lookup the address for a symbol. Returns 0 if not found. */
76107 unsigned long kallsyms_lookup_name(const char *name);
76108
76109 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
76110 /* Stupid that this does nothing, but I didn't create this mess. */
76111 #define __print_symbol(fmt, addr)
76112 #endif /*CONFIG_KALLSYMS*/
76113 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
76114 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
76115 +extern unsigned long kallsyms_lookup_name(const char *name);
76116 +extern void __print_symbol(const char *fmt, unsigned long address);
76117 +extern int sprint_backtrace(char *buffer, unsigned long address);
76118 +extern int sprint_symbol(char *buffer, unsigned long address);
76119 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
76120 +const char *kallsyms_lookup(unsigned long addr,
76121 + unsigned long *symbolsize,
76122 + unsigned long *offset,
76123 + char **modname, char *namebuf);
76124 +extern int kallsyms_lookup_size_offset(unsigned long addr,
76125 + unsigned long *symbolsize,
76126 + unsigned long *offset);
76127 +#endif
76128
76129 /* This macro allows us to keep printk typechecking */
76130 static __printf(1, 2)
76131 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
76132 index 518a53a..5e28358 100644
76133 --- a/include/linux/key-type.h
76134 +++ b/include/linux/key-type.h
76135 @@ -125,7 +125,7 @@ struct key_type {
76136 /* internal fields */
76137 struct list_head link; /* link in types list */
76138 struct lock_class_key lock_class; /* key->sem lock class */
76139 -};
76140 +} __do_const;
76141
76142 extern struct key_type key_type_keyring;
76143
76144 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
76145 index c6e091b..a940adf 100644
76146 --- a/include/linux/kgdb.h
76147 +++ b/include/linux/kgdb.h
76148 @@ -52,7 +52,7 @@ extern int kgdb_connected;
76149 extern int kgdb_io_module_registered;
76150
76151 extern atomic_t kgdb_setting_breakpoint;
76152 -extern atomic_t kgdb_cpu_doing_single_step;
76153 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
76154
76155 extern struct task_struct *kgdb_usethread;
76156 extern struct task_struct *kgdb_contthread;
76157 @@ -254,7 +254,7 @@ struct kgdb_arch {
76158 void (*correct_hw_break)(void);
76159
76160 void (*enable_nmi)(bool on);
76161 -};
76162 +} __do_const;
76163
76164 /**
76165 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
76166 @@ -279,7 +279,7 @@ struct kgdb_io {
76167 void (*pre_exception) (void);
76168 void (*post_exception) (void);
76169 int is_console;
76170 -};
76171 +} __do_const;
76172
76173 extern struct kgdb_arch arch_kgdb_ops;
76174
76175 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
76176 index 0555cc6..b16a7a4 100644
76177 --- a/include/linux/kmod.h
76178 +++ b/include/linux/kmod.h
76179 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
76180 * usually useless though. */
76181 extern __printf(2, 3)
76182 int __request_module(bool wait, const char *name, ...);
76183 +extern __printf(3, 4)
76184 +int ___request_module(bool wait, char *param_name, const char *name, ...);
76185 #define request_module(mod...) __request_module(true, mod)
76186 #define request_module_nowait(mod...) __request_module(false, mod)
76187 #define try_then_request_module(x, mod...) \
76188 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
76189 index 939b112..ed6ed51 100644
76190 --- a/include/linux/kobject.h
76191 +++ b/include/linux/kobject.h
76192 @@ -111,7 +111,7 @@ struct kobj_type {
76193 struct attribute **default_attrs;
76194 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
76195 const void *(*namespace)(struct kobject *kobj);
76196 -};
76197 +} __do_const;
76198
76199 struct kobj_uevent_env {
76200 char *envp[UEVENT_NUM_ENVP];
76201 @@ -134,6 +134,7 @@ struct kobj_attribute {
76202 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
76203 const char *buf, size_t count);
76204 };
76205 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
76206
76207 extern const struct sysfs_ops kobj_sysfs_ops;
76208
76209 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
76210 index f66b065..c2c29b4 100644
76211 --- a/include/linux/kobject_ns.h
76212 +++ b/include/linux/kobject_ns.h
76213 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
76214 const void *(*netlink_ns)(struct sock *sk);
76215 const void *(*initial_ns)(void);
76216 void (*drop_ns)(void *);
76217 -};
76218 +} __do_const;
76219
76220 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
76221 int kobj_ns_type_registered(enum kobj_ns_type type);
76222 diff --git a/include/linux/kref.h b/include/linux/kref.h
76223 index 484604d..0f6c5b6 100644
76224 --- a/include/linux/kref.h
76225 +++ b/include/linux/kref.h
76226 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
76227 static inline int kref_sub(struct kref *kref, unsigned int count,
76228 void (*release)(struct kref *kref))
76229 {
76230 - WARN_ON(release == NULL);
76231 + BUG_ON(release == NULL);
76232
76233 if (atomic_sub_and_test((int) count, &kref->refcount)) {
76234 release(kref);
76235 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
76236 index 8db53cf..c21121d 100644
76237 --- a/include/linux/kvm_host.h
76238 +++ b/include/linux/kvm_host.h
76239 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
76240 {
76241 }
76242 #endif
76243 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76244 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76245 struct module *module);
76246 void kvm_exit(void);
76247
76248 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
76249 struct kvm_guest_debug *dbg);
76250 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
76251
76252 -int kvm_arch_init(void *opaque);
76253 +int kvm_arch_init(const void *opaque);
76254 void kvm_arch_exit(void);
76255
76256 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
76257 diff --git a/include/linux/libata.h b/include/linux/libata.h
76258 index eae7a05..2cdd875 100644
76259 --- a/include/linux/libata.h
76260 +++ b/include/linux/libata.h
76261 @@ -919,7 +919,7 @@ struct ata_port_operations {
76262 * fields must be pointers.
76263 */
76264 const struct ata_port_operations *inherits;
76265 -};
76266 +} __do_const;
76267
76268 struct ata_port_info {
76269 unsigned long flags;
76270 diff --git a/include/linux/list.h b/include/linux/list.h
76271 index b83e565..baa6c1d 100644
76272 --- a/include/linux/list.h
76273 +++ b/include/linux/list.h
76274 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
76275 extern void list_del(struct list_head *entry);
76276 #endif
76277
76278 +extern void __pax_list_add(struct list_head *new,
76279 + struct list_head *prev,
76280 + struct list_head *next);
76281 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
76282 +{
76283 + __pax_list_add(new, head, head->next);
76284 +}
76285 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
76286 +{
76287 + __pax_list_add(new, head->prev, head);
76288 +}
76289 +extern void pax_list_del(struct list_head *entry);
76290 +
76291 /**
76292 * list_replace - replace old entry by new one
76293 * @old : the element to be replaced
76294 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
76295 INIT_LIST_HEAD(entry);
76296 }
76297
76298 +extern void pax_list_del_init(struct list_head *entry);
76299 +
76300 /**
76301 * list_move - delete from one list and add as another's head
76302 * @list: the entry to move
76303 diff --git a/include/linux/math64.h b/include/linux/math64.h
76304 index 2913b86..8dcbb1e 100644
76305 --- a/include/linux/math64.h
76306 +++ b/include/linux/math64.h
76307 @@ -15,7 +15,7 @@
76308 * This is commonly provided by 32bit archs to provide an optimized 64bit
76309 * divide.
76310 */
76311 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76312 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76313 {
76314 *remainder = dividend % divisor;
76315 return dividend / divisor;
76316 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
76317 /**
76318 * div64_u64 - unsigned 64bit divide with 64bit divisor
76319 */
76320 -static inline u64 div64_u64(u64 dividend, u64 divisor)
76321 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
76322 {
76323 return dividend / divisor;
76324 }
76325 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
76326 #define div64_ul(x, y) div_u64((x), (y))
76327
76328 #ifndef div_u64_rem
76329 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76330 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76331 {
76332 *remainder = do_div(dividend, divisor);
76333 return dividend;
76334 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
76335 * divide.
76336 */
76337 #ifndef div_u64
76338 -static inline u64 div_u64(u64 dividend, u32 divisor)
76339 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
76340 {
76341 u32 remainder;
76342 return div_u64_rem(dividend, divisor, &remainder);
76343 diff --git a/include/linux/mm.h b/include/linux/mm.h
76344 index e0c8528..bcf0c29 100644
76345 --- a/include/linux/mm.h
76346 +++ b/include/linux/mm.h
76347 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
76348 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
76349 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
76350 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
76351 +
76352 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
76353 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
76354 +#endif
76355 +
76356 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
76357
76358 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
76359 @@ -205,8 +210,8 @@ struct vm_operations_struct {
76360 /* called by access_process_vm when get_user_pages() fails, typically
76361 * for use by special VMAs that can switch between memory and hardware
76362 */
76363 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
76364 - void *buf, int len, int write);
76365 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
76366 + void *buf, size_t len, int write);
76367 #ifdef CONFIG_NUMA
76368 /*
76369 * set_policy() op must add a reference to any non-NULL @new mempolicy
76370 @@ -236,6 +241,7 @@ struct vm_operations_struct {
76371 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
76372 unsigned long size, pgoff_t pgoff);
76373 };
76374 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
76375
76376 struct mmu_gather;
76377 struct inode;
76378 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
76379 unsigned long *pfn);
76380 int follow_phys(struct vm_area_struct *vma, unsigned long address,
76381 unsigned int flags, unsigned long *prot, resource_size_t *phys);
76382 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76383 - void *buf, int len, int write);
76384 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76385 + void *buf, size_t len, int write);
76386
76387 static inline void unmap_shared_mapping_range(struct address_space *mapping,
76388 loff_t const holebegin, loff_t const holelen)
76389 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
76390 }
76391 #endif
76392
76393 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
76394 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
76395 - void *buf, int len, int write);
76396 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
76397 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
76398 + void *buf, size_t len, int write);
76399
76400 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
76401 unsigned long start, unsigned long nr_pages,
76402 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
76403 int set_page_dirty_lock(struct page *page);
76404 int clear_page_dirty_for_io(struct page *page);
76405
76406 -/* Is the vma a continuation of the stack vma above it? */
76407 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
76408 -{
76409 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
76410 -}
76411 -
76412 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76413 - unsigned long addr)
76414 -{
76415 - return (vma->vm_flags & VM_GROWSDOWN) &&
76416 - (vma->vm_start == addr) &&
76417 - !vma_growsdown(vma->vm_prev, addr);
76418 -}
76419 -
76420 -/* Is the vma a continuation of the stack vma below it? */
76421 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76422 -{
76423 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76424 -}
76425 -
76426 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76427 - unsigned long addr)
76428 -{
76429 - return (vma->vm_flags & VM_GROWSUP) &&
76430 - (vma->vm_end == addr) &&
76431 - !vma_growsup(vma->vm_next, addr);
76432 -}
76433 -
76434 extern pid_t
76435 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76436
76437 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76438 }
76439 #endif
76440
76441 +#ifdef CONFIG_MMU
76442 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76443 +#else
76444 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76445 +{
76446 + return __pgprot(0);
76447 +}
76448 +#endif
76449 +
76450 int vma_wants_writenotify(struct vm_area_struct *vma);
76451
76452 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76453 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76454 {
76455 return 0;
76456 }
76457 +
76458 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76459 + unsigned long address)
76460 +{
76461 + return 0;
76462 +}
76463 #else
76464 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76465 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76466 #endif
76467
76468 #ifdef __PAGETABLE_PMD_FOLDED
76469 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76470 {
76471 return 0;
76472 }
76473 +
76474 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76475 + unsigned long address)
76476 +{
76477 + return 0;
76478 +}
76479 #else
76480 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76481 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76482 #endif
76483
76484 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76485 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76486 NULL: pud_offset(pgd, address);
76487 }
76488
76489 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76490 +{
76491 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76492 + NULL: pud_offset(pgd, address);
76493 +}
76494 +
76495 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76496 {
76497 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76498 NULL: pmd_offset(pud, address);
76499 }
76500 +
76501 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76502 +{
76503 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76504 + NULL: pmd_offset(pud, address);
76505 +}
76506 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76507
76508 #if USE_SPLIT_PTLOCKS
76509 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76510 unsigned long len, unsigned long prot, unsigned long flags,
76511 unsigned long pgoff, unsigned long *populate);
76512 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76513 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76514
76515 #ifdef CONFIG_MMU
76516 extern int __mm_populate(unsigned long addr, unsigned long len,
76517 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
76518 unsigned long high_limit;
76519 unsigned long align_mask;
76520 unsigned long align_offset;
76521 + unsigned long threadstack_offset;
76522 };
76523
76524 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76525 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76526 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76527 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76528
76529 /*
76530 * Search for an unmapped address range.
76531 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76532 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76533 */
76534 static inline unsigned long
76535 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76536 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76537 {
76538 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76539 return unmapped_area(info);
76540 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76541 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76542 struct vm_area_struct **pprev);
76543
76544 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76545 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76546 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76547 +
76548 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76549 NULL if none. Assume start_addr < end_addr. */
76550 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76551 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76552 return vma;
76553 }
76554
76555 -#ifdef CONFIG_MMU
76556 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76557 -#else
76558 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76559 -{
76560 - return __pgprot(0);
76561 -}
76562 -#endif
76563 -
76564 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76565 unsigned long change_prot_numa(struct vm_area_struct *vma,
76566 unsigned long start, unsigned long end);
76567 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76568 static inline void vm_stat_account(struct mm_struct *mm,
76569 unsigned long flags, struct file *file, long pages)
76570 {
76571 +
76572 +#ifdef CONFIG_PAX_RANDMMAP
76573 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76574 +#endif
76575 +
76576 mm->total_vm += pages;
76577 }
76578 #endif /* CONFIG_PROC_FS */
76579 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
76580 extern int sysctl_memory_failure_early_kill;
76581 extern int sysctl_memory_failure_recovery;
76582 extern void shake_page(struct page *p, int access);
76583 -extern atomic_long_t num_poisoned_pages;
76584 +extern atomic_long_unchecked_t num_poisoned_pages;
76585 extern int soft_offline_page(struct page *page, int flags);
76586
76587 extern void dump_page(struct page *page);
76588 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
76589 static inline void setup_nr_node_ids(void) {}
76590 #endif
76591
76592 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76593 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76594 +#else
76595 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76596 +#endif
76597 +
76598 #endif /* __KERNEL__ */
76599 #endif /* _LINUX_MM_H */
76600 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76601 index 4a189ba..04101d6 100644
76602 --- a/include/linux/mm_types.h
76603 +++ b/include/linux/mm_types.h
76604 @@ -289,6 +289,8 @@ struct vm_area_struct {
76605 #ifdef CONFIG_NUMA
76606 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76607 #endif
76608 +
76609 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76610 };
76611
76612 struct core_thread {
76613 @@ -438,6 +440,24 @@ struct mm_struct {
76614 int first_nid;
76615 #endif
76616 struct uprobes_state uprobes_state;
76617 +
76618 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76619 + unsigned long pax_flags;
76620 +#endif
76621 +
76622 +#ifdef CONFIG_PAX_DLRESOLVE
76623 + unsigned long call_dl_resolve;
76624 +#endif
76625 +
76626 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76627 + unsigned long call_syscall;
76628 +#endif
76629 +
76630 +#ifdef CONFIG_PAX_ASLR
76631 + unsigned long delta_mmap; /* randomized offset */
76632 + unsigned long delta_stack; /* randomized offset */
76633 +#endif
76634 +
76635 };
76636
76637 /* first nid will either be a valid NID or one of these values */
76638 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76639 index c5d5278..f0b68c8 100644
76640 --- a/include/linux/mmiotrace.h
76641 +++ b/include/linux/mmiotrace.h
76642 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
76643 /* Called from ioremap.c */
76644 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
76645 void __iomem *addr);
76646 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
76647 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
76648
76649 /* For anyone to insert markers. Remember trailing newline. */
76650 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
76651 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
76652 {
76653 }
76654
76655 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
76656 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
76657 {
76658 }
76659
76660 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
76661 index 5c76737..61f518e 100644
76662 --- a/include/linux/mmzone.h
76663 +++ b/include/linux/mmzone.h
76664 @@ -396,7 +396,7 @@ struct zone {
76665 unsigned long flags; /* zone flags, see below */
76666
76667 /* Zone statistics */
76668 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76669 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76670
76671 /*
76672 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
76673 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
76674 index b508016..237cfe5 100644
76675 --- a/include/linux/mod_devicetable.h
76676 +++ b/include/linux/mod_devicetable.h
76677 @@ -13,7 +13,7 @@
76678 typedef unsigned long kernel_ulong_t;
76679 #endif
76680
76681 -#define PCI_ANY_ID (~0)
76682 +#define PCI_ANY_ID ((__u16)~0)
76683
76684 struct pci_device_id {
76685 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
76686 @@ -139,7 +139,7 @@ struct usb_device_id {
76687 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
76688 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
76689
76690 -#define HID_ANY_ID (~0)
76691 +#define HID_ANY_ID (~0U)
76692 #define HID_BUS_ANY 0xffff
76693 #define HID_GROUP_ANY 0x0000
76694
76695 @@ -465,7 +465,7 @@ struct dmi_system_id {
76696 const char *ident;
76697 struct dmi_strmatch matches[4];
76698 void *driver_data;
76699 -};
76700 +} __do_const;
76701 /*
76702 * struct dmi_device_id appears during expansion of
76703 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
76704 diff --git a/include/linux/module.h b/include/linux/module.h
76705 index 46f1ea0..a34ca37 100644
76706 --- a/include/linux/module.h
76707 +++ b/include/linux/module.h
76708 @@ -17,9 +17,11 @@
76709 #include <linux/moduleparam.h>
76710 #include <linux/tracepoint.h>
76711 #include <linux/export.h>
76712 +#include <linux/fs.h>
76713
76714 #include <linux/percpu.h>
76715 #include <asm/module.h>
76716 +#include <asm/pgtable.h>
76717
76718 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
76719 #define MODULE_SIG_STRING "~Module signature appended~\n"
76720 @@ -54,12 +56,13 @@ struct module_attribute {
76721 int (*test)(struct module *);
76722 void (*free)(struct module *);
76723 };
76724 +typedef struct module_attribute __no_const module_attribute_no_const;
76725
76726 struct module_version_attribute {
76727 struct module_attribute mattr;
76728 const char *module_name;
76729 const char *version;
76730 -} __attribute__ ((__aligned__(sizeof(void *))));
76731 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
76732
76733 extern ssize_t __modver_version_show(struct module_attribute *,
76734 struct module_kobject *, char *);
76735 @@ -232,7 +235,7 @@ struct module
76736
76737 /* Sysfs stuff. */
76738 struct module_kobject mkobj;
76739 - struct module_attribute *modinfo_attrs;
76740 + module_attribute_no_const *modinfo_attrs;
76741 const char *version;
76742 const char *srcversion;
76743 struct kobject *holders_dir;
76744 @@ -281,19 +284,16 @@ struct module
76745 int (*init)(void);
76746
76747 /* If this is non-NULL, vfree after init() returns */
76748 - void *module_init;
76749 + void *module_init_rx, *module_init_rw;
76750
76751 /* Here is the actual code + data, vfree'd on unload. */
76752 - void *module_core;
76753 + void *module_core_rx, *module_core_rw;
76754
76755 /* Here are the sizes of the init and core sections */
76756 - unsigned int init_size, core_size;
76757 + unsigned int init_size_rw, core_size_rw;
76758
76759 /* The size of the executable code in each section. */
76760 - unsigned int init_text_size, core_text_size;
76761 -
76762 - /* Size of RO sections of the module (text+rodata) */
76763 - unsigned int init_ro_size, core_ro_size;
76764 + unsigned int init_size_rx, core_size_rx;
76765
76766 /* Arch-specific module values */
76767 struct mod_arch_specific arch;
76768 @@ -349,6 +349,10 @@ struct module
76769 #ifdef CONFIG_EVENT_TRACING
76770 struct ftrace_event_call **trace_events;
76771 unsigned int num_trace_events;
76772 + struct file_operations trace_id;
76773 + struct file_operations trace_enable;
76774 + struct file_operations trace_format;
76775 + struct file_operations trace_filter;
76776 #endif
76777 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
76778 unsigned int num_ftrace_callsites;
76779 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
76780 bool is_module_percpu_address(unsigned long addr);
76781 bool is_module_text_address(unsigned long addr);
76782
76783 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
76784 +{
76785 +
76786 +#ifdef CONFIG_PAX_KERNEXEC
76787 + if (ktla_ktva(addr) >= (unsigned long)start &&
76788 + ktla_ktva(addr) < (unsigned long)start + size)
76789 + return 1;
76790 +#endif
76791 +
76792 + return ((void *)addr >= start && (void *)addr < start + size);
76793 +}
76794 +
76795 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
76796 +{
76797 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
76798 +}
76799 +
76800 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
76801 +{
76802 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
76803 +}
76804 +
76805 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
76806 +{
76807 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
76808 +}
76809 +
76810 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
76811 +{
76812 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
76813 +}
76814 +
76815 static inline int within_module_core(unsigned long addr, const struct module *mod)
76816 {
76817 - return (unsigned long)mod->module_core <= addr &&
76818 - addr < (unsigned long)mod->module_core + mod->core_size;
76819 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
76820 }
76821
76822 static inline int within_module_init(unsigned long addr, const struct module *mod)
76823 {
76824 - return (unsigned long)mod->module_init <= addr &&
76825 - addr < (unsigned long)mod->module_init + mod->init_size;
76826 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
76827 }
76828
76829 /* Search for module by name: must hold module_mutex. */
76830 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
76831 index 560ca53..ef621ef 100644
76832 --- a/include/linux/moduleloader.h
76833 +++ b/include/linux/moduleloader.h
76834 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
76835 sections. Returns NULL on failure. */
76836 void *module_alloc(unsigned long size);
76837
76838 +#ifdef CONFIG_PAX_KERNEXEC
76839 +void *module_alloc_exec(unsigned long size);
76840 +#else
76841 +#define module_alloc_exec(x) module_alloc(x)
76842 +#endif
76843 +
76844 /* Free memory returned from module_alloc. */
76845 void module_free(struct module *mod, void *module_region);
76846
76847 +#ifdef CONFIG_PAX_KERNEXEC
76848 +void module_free_exec(struct module *mod, void *module_region);
76849 +#else
76850 +#define module_free_exec(x, y) module_free((x), (y))
76851 +#endif
76852 +
76853 /*
76854 * Apply the given relocation to the (simplified) ELF. Return -error
76855 * or 0.
76856 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
76857 unsigned int relsec,
76858 struct module *me)
76859 {
76860 +#ifdef CONFIG_MODULES
76861 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76862 +#endif
76863 return -ENOEXEC;
76864 }
76865 #endif
76866 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
76867 unsigned int relsec,
76868 struct module *me)
76869 {
76870 +#ifdef CONFIG_MODULES
76871 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76872 +#endif
76873 return -ENOEXEC;
76874 }
76875 #endif
76876 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
76877 index 137b419..fe663ec 100644
76878 --- a/include/linux/moduleparam.h
76879 +++ b/include/linux/moduleparam.h
76880 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
76881 * @len is usually just sizeof(string).
76882 */
76883 #define module_param_string(name, string, len, perm) \
76884 - static const struct kparam_string __param_string_##name \
76885 + static const struct kparam_string __param_string_##name __used \
76886 = { len, string }; \
76887 __module_param_call(MODULE_PARAM_PREFIX, name, \
76888 &param_ops_string, \
76889 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
76890 */
76891 #define module_param_array_named(name, array, type, nump, perm) \
76892 param_check_##type(name, &(array)[0]); \
76893 - static const struct kparam_array __param_arr_##name \
76894 + static const struct kparam_array __param_arr_##name __used \
76895 = { .max = ARRAY_SIZE(array), .num = nump, \
76896 .ops = &param_ops_##type, \
76897 .elemsize = sizeof(array[0]), .elem = array }; \
76898 diff --git a/include/linux/namei.h b/include/linux/namei.h
76899 index 5a5ff57..5ae5070 100644
76900 --- a/include/linux/namei.h
76901 +++ b/include/linux/namei.h
76902 @@ -19,7 +19,7 @@ struct nameidata {
76903 unsigned seq;
76904 int last_type;
76905 unsigned depth;
76906 - char *saved_names[MAX_NESTED_LINKS + 1];
76907 + const char *saved_names[MAX_NESTED_LINKS + 1];
76908 };
76909
76910 /*
76911 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
76912
76913 extern void nd_jump_link(struct nameidata *nd, struct path *path);
76914
76915 -static inline void nd_set_link(struct nameidata *nd, char *path)
76916 +static inline void nd_set_link(struct nameidata *nd, const char *path)
76917 {
76918 nd->saved_names[nd->depth] = path;
76919 }
76920
76921 -static inline char *nd_get_link(struct nameidata *nd)
76922 +static inline const char *nd_get_link(const struct nameidata *nd)
76923 {
76924 return nd->saved_names[nd->depth];
76925 }
76926 diff --git a/include/linux/net.h b/include/linux/net.h
76927 index 99c9f0c..e1cf296 100644
76928 --- a/include/linux/net.h
76929 +++ b/include/linux/net.h
76930 @@ -183,7 +183,7 @@ struct net_proto_family {
76931 int (*create)(struct net *net, struct socket *sock,
76932 int protocol, int kern);
76933 struct module *owner;
76934 -};
76935 +} __do_const;
76936
76937 struct iovec;
76938 struct kvec;
76939 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
76940 index 96e4c21..9cc8278 100644
76941 --- a/include/linux/netdevice.h
76942 +++ b/include/linux/netdevice.h
76943 @@ -1026,6 +1026,7 @@ struct net_device_ops {
76944 int (*ndo_change_carrier)(struct net_device *dev,
76945 bool new_carrier);
76946 };
76947 +typedef struct net_device_ops __no_const net_device_ops_no_const;
76948
76949 /*
76950 * The DEVICE structure.
76951 @@ -1094,7 +1095,7 @@ struct net_device {
76952 int iflink;
76953
76954 struct net_device_stats stats;
76955 - atomic_long_t rx_dropped; /* dropped packets by core network
76956 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
76957 * Do not use this in drivers.
76958 */
76959
76960 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
76961 index 0060fde..481c6ae 100644
76962 --- a/include/linux/netfilter.h
76963 +++ b/include/linux/netfilter.h
76964 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
76965 #endif
76966 /* Use the module struct to lock set/get code in place */
76967 struct module *owner;
76968 -};
76969 +} __do_const;
76970
76971 /* Function to register/unregister hook points. */
76972 int nf_register_hook(struct nf_hook_ops *reg);
76973 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
76974 index d80e275..c3510b8 100644
76975 --- a/include/linux/netfilter/ipset/ip_set.h
76976 +++ b/include/linux/netfilter/ipset/ip_set.h
76977 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
76978 /* Return true if "b" set is the same as "a"
76979 * according to the create set parameters */
76980 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
76981 -};
76982 +} __do_const;
76983
76984 /* The core set type structure */
76985 struct ip_set_type {
76986 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
76987 index cadb740..d7c37c0 100644
76988 --- a/include/linux/netfilter/nfnetlink.h
76989 +++ b/include/linux/netfilter/nfnetlink.h
76990 @@ -16,7 +16,7 @@ struct nfnl_callback {
76991 const struct nlattr * const cda[]);
76992 const struct nla_policy *policy; /* netlink attribute policy */
76993 const u_int16_t attr_count; /* number of nlattr's */
76994 -};
76995 +} __do_const;
76996
76997 struct nfnetlink_subsystem {
76998 const char *name;
76999 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
77000 new file mode 100644
77001 index 0000000..33f4af8
77002 --- /dev/null
77003 +++ b/include/linux/netfilter/xt_gradm.h
77004 @@ -0,0 +1,9 @@
77005 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
77006 +#define _LINUX_NETFILTER_XT_GRADM_H 1
77007 +
77008 +struct xt_gradm_mtinfo {
77009 + __u16 flags;
77010 + __u16 invflags;
77011 +};
77012 +
77013 +#endif
77014 diff --git a/include/linux/nls.h b/include/linux/nls.h
77015 index 5dc635f..35f5e11 100644
77016 --- a/include/linux/nls.h
77017 +++ b/include/linux/nls.h
77018 @@ -31,7 +31,7 @@ struct nls_table {
77019 const unsigned char *charset2upper;
77020 struct module *owner;
77021 struct nls_table *next;
77022 -};
77023 +} __do_const;
77024
77025 /* this value hold the maximum octet of charset */
77026 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
77027 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
77028 index d14a4c3..a078786 100644
77029 --- a/include/linux/notifier.h
77030 +++ b/include/linux/notifier.h
77031 @@ -54,7 +54,8 @@ struct notifier_block {
77032 notifier_fn_t notifier_call;
77033 struct notifier_block __rcu *next;
77034 int priority;
77035 -};
77036 +} __do_const;
77037 +typedef struct notifier_block __no_const notifier_block_no_const;
77038
77039 struct atomic_notifier_head {
77040 spinlock_t lock;
77041 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
77042 index a4c5624..79d6d88 100644
77043 --- a/include/linux/oprofile.h
77044 +++ b/include/linux/oprofile.h
77045 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
77046 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
77047 char const * name, ulong * val);
77048
77049 -/** Create a file for read-only access to an atomic_t. */
77050 +/** Create a file for read-only access to an atomic_unchecked_t. */
77051 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
77052 - char const * name, atomic_t * val);
77053 + char const * name, atomic_unchecked_t * val);
77054
77055 /** create a directory */
77056 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
77057 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
77058 index 8db71dc..a76bf2c 100644
77059 --- a/include/linux/pci_hotplug.h
77060 +++ b/include/linux/pci_hotplug.h
77061 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
77062 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
77063 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
77064 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
77065 -};
77066 +} __do_const;
77067 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
77068
77069 /**
77070 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
77071 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
77072 index c5b6dbf..b124155 100644
77073 --- a/include/linux/perf_event.h
77074 +++ b/include/linux/perf_event.h
77075 @@ -318,8 +318,8 @@ struct perf_event {
77076
77077 enum perf_event_active_state state;
77078 unsigned int attach_state;
77079 - local64_t count;
77080 - atomic64_t child_count;
77081 + local64_t count; /* PaX: fix it one day */
77082 + atomic64_unchecked_t child_count;
77083
77084 /*
77085 * These are the total time in nanoseconds that the event
77086 @@ -370,8 +370,8 @@ struct perf_event {
77087 * These accumulate total time (in nanoseconds) that children
77088 * events have been enabled and running, respectively.
77089 */
77090 - atomic64_t child_total_time_enabled;
77091 - atomic64_t child_total_time_running;
77092 + atomic64_unchecked_t child_total_time_enabled;
77093 + atomic64_unchecked_t child_total_time_running;
77094
77095 /*
77096 * Protect attach/detach and child_list:
77097 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
77098 entry->ip[entry->nr++] = ip;
77099 }
77100
77101 -extern int sysctl_perf_event_paranoid;
77102 +extern int sysctl_perf_event_legitimately_concerned;
77103 extern int sysctl_perf_event_mlock;
77104 extern int sysctl_perf_event_sample_rate;
77105
77106 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
77107 void __user *buffer, size_t *lenp,
77108 loff_t *ppos);
77109
77110 +static inline bool perf_paranoid_any(void)
77111 +{
77112 + return sysctl_perf_event_legitimately_concerned > 2;
77113 +}
77114 +
77115 static inline bool perf_paranoid_tracepoint_raw(void)
77116 {
77117 - return sysctl_perf_event_paranoid > -1;
77118 + return sysctl_perf_event_legitimately_concerned > -1;
77119 }
77120
77121 static inline bool perf_paranoid_cpu(void)
77122 {
77123 - return sysctl_perf_event_paranoid > 0;
77124 + return sysctl_perf_event_legitimately_concerned > 0;
77125 }
77126
77127 static inline bool perf_paranoid_kernel(void)
77128 {
77129 - return sysctl_perf_event_paranoid > 1;
77130 + return sysctl_perf_event_legitimately_concerned > 1;
77131 }
77132
77133 extern void perf_event_init(void);
77134 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
77135 */
77136 #define perf_cpu_notifier(fn) \
77137 do { \
77138 - static struct notifier_block fn##_nb __cpuinitdata = \
77139 + static struct notifier_block fn##_nb = \
77140 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
77141 unsigned long cpu = smp_processor_id(); \
77142 unsigned long flags; \
77143 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
77144 struct device_attribute attr;
77145 u64 id;
77146 const char *event_str;
77147 -};
77148 +} __do_const;
77149
77150 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
77151 static struct perf_pmu_events_attr _var = { \
77152 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
77153 index b8809fe..ae4ccd0 100644
77154 --- a/include/linux/pipe_fs_i.h
77155 +++ b/include/linux/pipe_fs_i.h
77156 @@ -47,10 +47,10 @@ struct pipe_inode_info {
77157 struct mutex mutex;
77158 wait_queue_head_t wait;
77159 unsigned int nrbufs, curbuf, buffers;
77160 - unsigned int readers;
77161 - unsigned int writers;
77162 - unsigned int files;
77163 - unsigned int waiting_writers;
77164 + atomic_t readers;
77165 + atomic_t writers;
77166 + atomic_t files;
77167 + atomic_t waiting_writers;
77168 unsigned int r_counter;
77169 unsigned int w_counter;
77170 struct page *tmp_page;
77171 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
77172 index 5f28cae..3d23723 100644
77173 --- a/include/linux/platform_data/usb-ehci-s5p.h
77174 +++ b/include/linux/platform_data/usb-ehci-s5p.h
77175 @@ -14,7 +14,7 @@
77176 struct s5p_ehci_platdata {
77177 int (*phy_init)(struct platform_device *pdev, int type);
77178 int (*phy_exit)(struct platform_device *pdev, int type);
77179 -};
77180 +} __no_const;
77181
77182 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
77183
77184 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
77185 index c256c59..8ea94c7 100644
77186 --- a/include/linux/platform_data/usb-ohci-exynos.h
77187 +++ b/include/linux/platform_data/usb-ohci-exynos.h
77188 @@ -14,7 +14,7 @@
77189 struct exynos4_ohci_platdata {
77190 int (*phy_init)(struct platform_device *pdev, int type);
77191 int (*phy_exit)(struct platform_device *pdev, int type);
77192 -};
77193 +} __no_const;
77194
77195 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
77196
77197 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
77198 index 7c1d252..c5c773e 100644
77199 --- a/include/linux/pm_domain.h
77200 +++ b/include/linux/pm_domain.h
77201 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
77202
77203 struct gpd_cpu_data {
77204 unsigned int saved_exit_latency;
77205 - struct cpuidle_state *idle_state;
77206 + cpuidle_state_no_const *idle_state;
77207 };
77208
77209 struct generic_pm_domain {
77210 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
77211 index 7d7e09e..8671ef8 100644
77212 --- a/include/linux/pm_runtime.h
77213 +++ b/include/linux/pm_runtime.h
77214 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
77215
77216 static inline void pm_runtime_mark_last_busy(struct device *dev)
77217 {
77218 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
77219 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
77220 }
77221
77222 #else /* !CONFIG_PM_RUNTIME */
77223 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
77224 index 195aafc..49a7bc2 100644
77225 --- a/include/linux/pnp.h
77226 +++ b/include/linux/pnp.h
77227 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
77228 struct pnp_fixup {
77229 char id[7];
77230 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
77231 -};
77232 +} __do_const;
77233
77234 /* config parameters */
77235 #define PNP_CONFIG_NORMAL 0x0001
77236 diff --git a/include/linux/poison.h b/include/linux/poison.h
77237 index 2110a81..13a11bb 100644
77238 --- a/include/linux/poison.h
77239 +++ b/include/linux/poison.h
77240 @@ -19,8 +19,8 @@
77241 * under normal circumstances, used to verify that nobody uses
77242 * non-initialized list entries.
77243 */
77244 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
77245 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
77246 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
77247 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
77248
77249 /********** include/linux/timer.h **********/
77250 /*
77251 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
77252 index c0f44c2..1572583 100644
77253 --- a/include/linux/power/smartreflex.h
77254 +++ b/include/linux/power/smartreflex.h
77255 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
77256 int (*notify)(struct omap_sr *sr, u32 status);
77257 u8 notify_flags;
77258 u8 class_type;
77259 -};
77260 +} __do_const;
77261
77262 /**
77263 * struct omap_sr_nvalue_table - Smartreflex n-target value info
77264 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
77265 index 4ea1d37..80f4b33 100644
77266 --- a/include/linux/ppp-comp.h
77267 +++ b/include/linux/ppp-comp.h
77268 @@ -84,7 +84,7 @@ struct compressor {
77269 struct module *owner;
77270 /* Extra skb space needed by the compressor algorithm */
77271 unsigned int comp_extra;
77272 -};
77273 +} __do_const;
77274
77275 /*
77276 * The return value from decompress routine is the length of the
77277 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
77278 index f5d4723..a6ea2fa 100644
77279 --- a/include/linux/preempt.h
77280 +++ b/include/linux/preempt.h
77281 @@ -18,8 +18,13 @@
77282 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77283 #endif
77284
77285 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
77286 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77287 +
77288 #define inc_preempt_count() add_preempt_count(1)
77289 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
77290 #define dec_preempt_count() sub_preempt_count(1)
77291 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
77292
77293 #define preempt_count() (current_thread_info()->preempt_count)
77294
77295 @@ -64,6 +69,12 @@ do { \
77296 barrier(); \
77297 } while (0)
77298
77299 +#define raw_preempt_disable() \
77300 +do { \
77301 + raw_inc_preempt_count(); \
77302 + barrier(); \
77303 +} while (0)
77304 +
77305 #define sched_preempt_enable_no_resched() \
77306 do { \
77307 barrier(); \
77308 @@ -72,6 +83,12 @@ do { \
77309
77310 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
77311
77312 +#define raw_preempt_enable_no_resched() \
77313 +do { \
77314 + barrier(); \
77315 + raw_dec_preempt_count(); \
77316 +} while (0)
77317 +
77318 #define preempt_enable() \
77319 do { \
77320 preempt_enable_no_resched(); \
77321 @@ -116,8 +133,10 @@ do { \
77322 * region.
77323 */
77324 #define preempt_disable() barrier()
77325 +#define raw_preempt_disable() barrier()
77326 #define sched_preempt_enable_no_resched() barrier()
77327 #define preempt_enable_no_resched() barrier()
77328 +#define raw_preempt_enable_no_resched() barrier()
77329 #define preempt_enable() barrier()
77330
77331 #define preempt_disable_notrace() barrier()
77332 diff --git a/include/linux/printk.h b/include/linux/printk.h
77333 index 22c7052..ad3fa0a 100644
77334 --- a/include/linux/printk.h
77335 +++ b/include/linux/printk.h
77336 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
77337 void early_printk(const char *s, ...) { }
77338 #endif
77339
77340 +extern int kptr_restrict;
77341 +
77342 #ifdef CONFIG_PRINTK
77343 asmlinkage __printf(5, 0)
77344 int vprintk_emit(int facility, int level,
77345 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
77346
77347 extern int printk_delay_msec;
77348 extern int dmesg_restrict;
77349 -extern int kptr_restrict;
77350
77351 extern void wake_up_klogd(void);
77352
77353 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
77354 index 608e60a..c26f864 100644
77355 --- a/include/linux/proc_fs.h
77356 +++ b/include/linux/proc_fs.h
77357 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
77358 return proc_create_data(name, mode, parent, proc_fops, NULL);
77359 }
77360
77361 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
77362 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
77363 +{
77364 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77365 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
77366 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77367 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
77368 +#else
77369 + return proc_create_data(name, mode, parent, proc_fops, NULL);
77370 +#endif
77371 +}
77372 +
77373 +
77374 extern void proc_set_size(struct proc_dir_entry *, loff_t);
77375 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
77376 extern void *PDE_DATA(const struct inode *);
77377 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
77378 index 34a1e10..03a6d03 100644
77379 --- a/include/linux/proc_ns.h
77380 +++ b/include/linux/proc_ns.h
77381 @@ -14,7 +14,7 @@ struct proc_ns_operations {
77382 void (*put)(void *ns);
77383 int (*install)(struct nsproxy *nsproxy, void *ns);
77384 unsigned int (*inum)(void *ns);
77385 -};
77386 +} __do_const;
77387
77388 struct proc_ns {
77389 void *ns;
77390 diff --git a/include/linux/random.h b/include/linux/random.h
77391 index 3b9377d..61b506a 100644
77392 --- a/include/linux/random.h
77393 +++ b/include/linux/random.h
77394 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
77395 u32 prandom_u32_state(struct rnd_state *);
77396 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77397
77398 +static inline unsigned long pax_get_random_long(void)
77399 +{
77400 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77401 +}
77402 +
77403 /*
77404 * Handle minimum values for seeds
77405 */
77406 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77407 index f4b1001..8ddb2b6 100644
77408 --- a/include/linux/rculist.h
77409 +++ b/include/linux/rculist.h
77410 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77411 struct list_head *prev, struct list_head *next);
77412 #endif
77413
77414 +extern void __pax_list_add_rcu(struct list_head *new,
77415 + struct list_head *prev, struct list_head *next);
77416 +
77417 /**
77418 * list_add_rcu - add a new entry to rcu-protected list
77419 * @new: new entry to be added
77420 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77421 __list_add_rcu(new, head, head->next);
77422 }
77423
77424 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77425 +{
77426 + __pax_list_add_rcu(new, head, head->next);
77427 +}
77428 +
77429 /**
77430 * list_add_tail_rcu - add a new entry to rcu-protected list
77431 * @new: new entry to be added
77432 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77433 __list_add_rcu(new, head->prev, head);
77434 }
77435
77436 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77437 + struct list_head *head)
77438 +{
77439 + __pax_list_add_rcu(new, head->prev, head);
77440 +}
77441 +
77442 /**
77443 * list_del_rcu - deletes entry from list without re-initialization
77444 * @entry: the element to delete from the list.
77445 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77446 entry->prev = LIST_POISON2;
77447 }
77448
77449 +extern void pax_list_del_rcu(struct list_head *entry);
77450 +
77451 /**
77452 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77453 * @n: the element to delete from the hash list.
77454 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77455 index 23b3630..e1bc12b 100644
77456 --- a/include/linux/reboot.h
77457 +++ b/include/linux/reboot.h
77458 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77459 * Architecture-specific implementations of sys_reboot commands.
77460 */
77461
77462 -extern void machine_restart(char *cmd);
77463 -extern void machine_halt(void);
77464 -extern void machine_power_off(void);
77465 +extern void machine_restart(char *cmd) __noreturn;
77466 +extern void machine_halt(void) __noreturn;
77467 +extern void machine_power_off(void) __noreturn;
77468
77469 extern void machine_shutdown(void);
77470 struct pt_regs;
77471 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77472 */
77473
77474 extern void kernel_restart_prepare(char *cmd);
77475 -extern void kernel_restart(char *cmd);
77476 -extern void kernel_halt(void);
77477 -extern void kernel_power_off(void);
77478 +extern void kernel_restart(char *cmd) __noreturn;
77479 +extern void kernel_halt(void) __noreturn;
77480 +extern void kernel_power_off(void) __noreturn;
77481
77482 extern int C_A_D; /* for sysctl */
77483 void ctrl_alt_del(void);
77484 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
77485 * Emergency restart, callable from an interrupt handler.
77486 */
77487
77488 -extern void emergency_restart(void);
77489 +extern void emergency_restart(void) __noreturn;
77490 #include <asm/emergency-restart.h>
77491
77492 #endif /* _LINUX_REBOOT_H */
77493 diff --git a/include/linux/regset.h b/include/linux/regset.h
77494 index 8e0c9fe..ac4d221 100644
77495 --- a/include/linux/regset.h
77496 +++ b/include/linux/regset.h
77497 @@ -161,7 +161,8 @@ struct user_regset {
77498 unsigned int align;
77499 unsigned int bias;
77500 unsigned int core_note_type;
77501 -};
77502 +} __do_const;
77503 +typedef struct user_regset __no_const user_regset_no_const;
77504
77505 /**
77506 * struct user_regset_view - available regsets
77507 diff --git a/include/linux/relay.h b/include/linux/relay.h
77508 index d7c8359..818daf5 100644
77509 --- a/include/linux/relay.h
77510 +++ b/include/linux/relay.h
77511 @@ -157,7 +157,7 @@ struct rchan_callbacks
77512 * The callback should return 0 if successful, negative if not.
77513 */
77514 int (*remove_buf_file)(struct dentry *dentry);
77515 -};
77516 +} __no_const;
77517
77518 /*
77519 * CONFIG_RELAY kernel API, kernel/relay.c
77520 diff --git a/include/linux/rio.h b/include/linux/rio.h
77521 index 18e0993..8ab5b21 100644
77522 --- a/include/linux/rio.h
77523 +++ b/include/linux/rio.h
77524 @@ -345,7 +345,7 @@ struct rio_ops {
77525 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77526 u64 rstart, u32 size, u32 flags);
77527 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77528 -};
77529 +} __no_const;
77530
77531 #define RIO_RESOURCE_MEM 0x00000100
77532 #define RIO_RESOURCE_DOORBELL 0x00000200
77533 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77534 index 6dacb93..6174423 100644
77535 --- a/include/linux/rmap.h
77536 +++ b/include/linux/rmap.h
77537 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77538 void anon_vma_init(void); /* create anon_vma_cachep */
77539 int anon_vma_prepare(struct vm_area_struct *);
77540 void unlink_anon_vmas(struct vm_area_struct *);
77541 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77542 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77543 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77544 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77545
77546 static inline void anon_vma_merge(struct vm_area_struct *vma,
77547 struct vm_area_struct *next)
77548 diff --git a/include/linux/sched.h b/include/linux/sched.h
77549 index 178a8d9..918ea01 100644
77550 --- a/include/linux/sched.h
77551 +++ b/include/linux/sched.h
77552 @@ -62,6 +62,7 @@ struct bio_list;
77553 struct fs_struct;
77554 struct perf_event_context;
77555 struct blk_plug;
77556 +struct linux_binprm;
77557
77558 /*
77559 * List of flags we want to share for kernel threads,
77560 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
77561 extern int in_sched_functions(unsigned long addr);
77562
77563 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77564 -extern signed long schedule_timeout(signed long timeout);
77565 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77566 extern signed long schedule_timeout_interruptible(signed long timeout);
77567 extern signed long schedule_timeout_killable(signed long timeout);
77568 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77569 @@ -314,6 +315,18 @@ struct nsproxy;
77570 struct user_namespace;
77571
77572 #ifdef CONFIG_MMU
77573 +
77574 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77575 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77576 +#else
77577 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77578 +{
77579 + return 0;
77580 +}
77581 +#endif
77582 +
77583 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77584 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77585 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77586 extern unsigned long
77587 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77588 @@ -591,6 +604,17 @@ struct signal_struct {
77589 #ifdef CONFIG_TASKSTATS
77590 struct taskstats *stats;
77591 #endif
77592 +
77593 +#ifdef CONFIG_GRKERNSEC
77594 + u32 curr_ip;
77595 + u32 saved_ip;
77596 + u32 gr_saddr;
77597 + u32 gr_daddr;
77598 + u16 gr_sport;
77599 + u16 gr_dport;
77600 + u8 used_accept:1;
77601 +#endif
77602 +
77603 #ifdef CONFIG_AUDIT
77604 unsigned audit_tty;
77605 unsigned audit_tty_log_passwd;
77606 @@ -671,6 +695,14 @@ struct user_struct {
77607 struct key *session_keyring; /* UID's default session keyring */
77608 #endif
77609
77610 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
77611 + unsigned char kernel_banned;
77612 +#endif
77613 +#ifdef CONFIG_GRKERNSEC_BRUTE
77614 + unsigned char suid_banned;
77615 + unsigned long suid_ban_expires;
77616 +#endif
77617 +
77618 /* Hash table maintenance information */
77619 struct hlist_node uidhash_node;
77620 kuid_t uid;
77621 @@ -1158,8 +1190,8 @@ struct task_struct {
77622 struct list_head thread_group;
77623
77624 struct completion *vfork_done; /* for vfork() */
77625 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
77626 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77627 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
77628 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77629
77630 cputime_t utime, stime, utimescaled, stimescaled;
77631 cputime_t gtime;
77632 @@ -1184,11 +1216,6 @@ struct task_struct {
77633 struct task_cputime cputime_expires;
77634 struct list_head cpu_timers[3];
77635
77636 -/* process credentials */
77637 - const struct cred __rcu *real_cred; /* objective and real subjective task
77638 - * credentials (COW) */
77639 - const struct cred __rcu *cred; /* effective (overridable) subjective task
77640 - * credentials (COW) */
77641 char comm[TASK_COMM_LEN]; /* executable name excluding path
77642 - access with [gs]et_task_comm (which lock
77643 it with task_lock())
77644 @@ -1205,6 +1232,10 @@ struct task_struct {
77645 #endif
77646 /* CPU-specific state of this task */
77647 struct thread_struct thread;
77648 +/* thread_info moved to task_struct */
77649 +#ifdef CONFIG_X86
77650 + struct thread_info tinfo;
77651 +#endif
77652 /* filesystem information */
77653 struct fs_struct *fs;
77654 /* open file information */
77655 @@ -1278,6 +1309,10 @@ struct task_struct {
77656 gfp_t lockdep_reclaim_gfp;
77657 #endif
77658
77659 +/* process credentials */
77660 + const struct cred __rcu *real_cred; /* objective and real subjective task
77661 + * credentials (COW) */
77662 +
77663 /* journalling filesystem info */
77664 void *journal_info;
77665
77666 @@ -1316,6 +1351,10 @@ struct task_struct {
77667 /* cg_list protected by css_set_lock and tsk->alloc_lock */
77668 struct list_head cg_list;
77669 #endif
77670 +
77671 + const struct cred __rcu *cred; /* effective (overridable) subjective task
77672 + * credentials (COW) */
77673 +
77674 #ifdef CONFIG_FUTEX
77675 struct robust_list_head __user *robust_list;
77676 #ifdef CONFIG_COMPAT
77677 @@ -1416,8 +1455,76 @@ struct task_struct {
77678 unsigned int sequential_io;
77679 unsigned int sequential_io_avg;
77680 #endif
77681 +
77682 +#ifdef CONFIG_GRKERNSEC
77683 + /* grsecurity */
77684 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77685 + u64 exec_id;
77686 +#endif
77687 +#ifdef CONFIG_GRKERNSEC_SETXID
77688 + const struct cred *delayed_cred;
77689 +#endif
77690 + struct dentry *gr_chroot_dentry;
77691 + struct acl_subject_label *acl;
77692 + struct acl_role_label *role;
77693 + struct file *exec_file;
77694 + unsigned long brute_expires;
77695 + u16 acl_role_id;
77696 + /* is this the task that authenticated to the special role */
77697 + u8 acl_sp_role;
77698 + u8 is_writable;
77699 + u8 brute;
77700 + u8 gr_is_chrooted;
77701 +#endif
77702 +
77703 };
77704
77705 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
77706 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
77707 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
77708 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
77709 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
77710 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
77711 +
77712 +#ifdef CONFIG_PAX_SOFTMODE
77713 +extern int pax_softmode;
77714 +#endif
77715 +
77716 +extern int pax_check_flags(unsigned long *);
77717 +
77718 +/* if tsk != current then task_lock must be held on it */
77719 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77720 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
77721 +{
77722 + if (likely(tsk->mm))
77723 + return tsk->mm->pax_flags;
77724 + else
77725 + return 0UL;
77726 +}
77727 +
77728 +/* if tsk != current then task_lock must be held on it */
77729 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
77730 +{
77731 + if (likely(tsk->mm)) {
77732 + tsk->mm->pax_flags = flags;
77733 + return 0;
77734 + }
77735 + return -EINVAL;
77736 +}
77737 +#endif
77738 +
77739 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
77740 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
77741 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
77742 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
77743 +#endif
77744 +
77745 +struct path;
77746 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
77747 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
77748 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
77749 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
77750 +
77751 /* Future-safe accessor for struct task_struct's cpus_allowed. */
77752 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
77753
77754 @@ -1476,7 +1583,7 @@ struct pid_namespace;
77755 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
77756 struct pid_namespace *ns);
77757
77758 -static inline pid_t task_pid_nr(struct task_struct *tsk)
77759 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
77760 {
77761 return tsk->pid;
77762 }
77763 @@ -1919,7 +2026,9 @@ void yield(void);
77764 extern struct exec_domain default_exec_domain;
77765
77766 union thread_union {
77767 +#ifndef CONFIG_X86
77768 struct thread_info thread_info;
77769 +#endif
77770 unsigned long stack[THREAD_SIZE/sizeof(long)];
77771 };
77772
77773 @@ -1952,6 +2061,7 @@ extern struct pid_namespace init_pid_ns;
77774 */
77775
77776 extern struct task_struct *find_task_by_vpid(pid_t nr);
77777 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
77778 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
77779 struct pid_namespace *ns);
77780
77781 @@ -2118,7 +2228,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
77782 extern void exit_itimers(struct signal_struct *);
77783 extern void flush_itimer_signals(void);
77784
77785 -extern void do_group_exit(int);
77786 +extern __noreturn void do_group_exit(int);
77787
77788 extern int allow_signal(int);
77789 extern int disallow_signal(int);
77790 @@ -2309,9 +2419,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
77791
77792 #endif
77793
77794 -static inline int object_is_on_stack(void *obj)
77795 +static inline int object_starts_on_stack(void *obj)
77796 {
77797 - void *stack = task_stack_page(current);
77798 + const void *stack = task_stack_page(current);
77799
77800 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
77801 }
77802 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
77803 index bf8086b..962b035 100644
77804 --- a/include/linux/sched/sysctl.h
77805 +++ b/include/linux/sched/sysctl.h
77806 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
77807 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
77808
77809 extern int sysctl_max_map_count;
77810 +extern unsigned long sysctl_heap_stack_gap;
77811
77812 extern unsigned int sysctl_sched_latency;
77813 extern unsigned int sysctl_sched_min_granularity;
77814 diff --git a/include/linux/security.h b/include/linux/security.h
77815 index 4686491..2bd210e 100644
77816 --- a/include/linux/security.h
77817 +++ b/include/linux/security.h
77818 @@ -26,6 +26,7 @@
77819 #include <linux/capability.h>
77820 #include <linux/slab.h>
77821 #include <linux/err.h>
77822 +#include <linux/grsecurity.h>
77823
77824 struct linux_binprm;
77825 struct cred;
77826 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
77827 index 2da29ac..aac448ec 100644
77828 --- a/include/linux/seq_file.h
77829 +++ b/include/linux/seq_file.h
77830 @@ -26,6 +26,9 @@ struct seq_file {
77831 struct mutex lock;
77832 const struct seq_operations *op;
77833 int poll_event;
77834 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77835 + u64 exec_id;
77836 +#endif
77837 #ifdef CONFIG_USER_NS
77838 struct user_namespace *user_ns;
77839 #endif
77840 @@ -38,6 +41,7 @@ struct seq_operations {
77841 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
77842 int (*show) (struct seq_file *m, void *v);
77843 };
77844 +typedef struct seq_operations __no_const seq_operations_no_const;
77845
77846 #define SEQ_SKIP 1
77847
77848 diff --git a/include/linux/shm.h b/include/linux/shm.h
77849 index 429c199..4d42e38 100644
77850 --- a/include/linux/shm.h
77851 +++ b/include/linux/shm.h
77852 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
77853
77854 /* The task created the shm object. NULL if the task is dead. */
77855 struct task_struct *shm_creator;
77856 +#ifdef CONFIG_GRKERNSEC
77857 + time_t shm_createtime;
77858 + pid_t shm_lapid;
77859 +#endif
77860 };
77861
77862 /* shm_mode upper byte flags */
77863 diff --git a/include/linux/signal.h b/include/linux/signal.h
77864 index d897484..323ba98 100644
77865 --- a/include/linux/signal.h
77866 +++ b/include/linux/signal.h
77867 @@ -433,6 +433,7 @@ void signals_init(void);
77868
77869 int restore_altstack(const stack_t __user *);
77870 int __save_altstack(stack_t __user *, unsigned long);
77871 +void __save_altstack_ex(stack_t __user *, unsigned long);
77872
77873 #ifdef CONFIG_PROC_FS
77874 struct seq_file;
77875 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
77876 index dec1748..112c1f9 100644
77877 --- a/include/linux/skbuff.h
77878 +++ b/include/linux/skbuff.h
77879 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
77880 extern struct sk_buff *__alloc_skb(unsigned int size,
77881 gfp_t priority, int flags, int node);
77882 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
77883 -static inline struct sk_buff *alloc_skb(unsigned int size,
77884 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
77885 gfp_t priority)
77886 {
77887 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
77888 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
77889 */
77890 static inline int skb_queue_empty(const struct sk_buff_head *list)
77891 {
77892 - return list->next == (struct sk_buff *)list;
77893 + return list->next == (const struct sk_buff *)list;
77894 }
77895
77896 /**
77897 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
77898 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77899 const struct sk_buff *skb)
77900 {
77901 - return skb->next == (struct sk_buff *)list;
77902 + return skb->next == (const struct sk_buff *)list;
77903 }
77904
77905 /**
77906 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77907 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
77908 const struct sk_buff *skb)
77909 {
77910 - return skb->prev == (struct sk_buff *)list;
77911 + return skb->prev == (const struct sk_buff *)list;
77912 }
77913
77914 /**
77915 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
77916 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
77917 */
77918 #ifndef NET_SKB_PAD
77919 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
77920 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
77921 #endif
77922
77923 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
77924 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
77925 int noblock, int *err);
77926 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
77927 struct poll_table_struct *wait);
77928 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
77929 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
77930 int offset, struct iovec *to,
77931 int size);
77932 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
77933 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
77934 nf_bridge_put(skb->nf_bridge);
77935 skb->nf_bridge = NULL;
77936 #endif
77937 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
77938 + skb->nf_trace = 0;
77939 +#endif
77940 }
77941
77942 static inline void nf_reset_trace(struct sk_buff *skb)
77943 diff --git a/include/linux/slab.h b/include/linux/slab.h
77944 index 0c62175..f016ac1 100644
77945 --- a/include/linux/slab.h
77946 +++ b/include/linux/slab.h
77947 @@ -12,15 +12,29 @@
77948 #include <linux/gfp.h>
77949 #include <linux/types.h>
77950 #include <linux/workqueue.h>
77951 -
77952 +#include <linux/err.h>
77953
77954 /*
77955 * Flags to pass to kmem_cache_create().
77956 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
77957 */
77958 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
77959 +
77960 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77961 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
77962 +#else
77963 +#define SLAB_USERCOPY 0x00000000UL
77964 +#endif
77965 +
77966 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
77967 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
77968 +
77969 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77970 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
77971 +#else
77972 +#define SLAB_NO_SANITIZE 0x00000000UL
77973 +#endif
77974 +
77975 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
77976 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
77977 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
77978 @@ -89,10 +103,13 @@
77979 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
77980 * Both make kfree a no-op.
77981 */
77982 -#define ZERO_SIZE_PTR ((void *)16)
77983 +#define ZERO_SIZE_PTR \
77984 +({ \
77985 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
77986 + (void *)(-MAX_ERRNO-1L); \
77987 +})
77988
77989 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
77990 - (unsigned long)ZERO_SIZE_PTR)
77991 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
77992
77993
77994 struct mem_cgroup;
77995 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
77996 void kfree(const void *);
77997 void kzfree(const void *);
77998 size_t ksize(const void *);
77999 +const char *check_heap_object(const void *ptr, unsigned long n);
78000 +bool is_usercopy_object(const void *ptr);
78001
78002 /*
78003 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
78004 @@ -164,7 +183,7 @@ struct kmem_cache {
78005 unsigned int align; /* Alignment as calculated */
78006 unsigned long flags; /* Active flags on the slab */
78007 const char *name; /* Slab name for sysfs */
78008 - int refcount; /* Use counter */
78009 + atomic_t refcount; /* Use counter */
78010 void (*ctor)(void *); /* Called on object slot creation */
78011 struct list_head list; /* List of all slab caches on the system */
78012 };
78013 @@ -226,6 +245,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
78014 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78015 #endif
78016
78017 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78018 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
78019 +#endif
78020 +
78021 /*
78022 * Figure out which kmalloc slab an allocation of a certain size
78023 * belongs to.
78024 @@ -234,7 +257,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78025 * 2 = 120 .. 192 bytes
78026 * n = 2^(n-1) .. 2^n -1
78027 */
78028 -static __always_inline int kmalloc_index(size_t size)
78029 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
78030 {
78031 if (!size)
78032 return 0;
78033 @@ -406,6 +429,7 @@ void print_slabinfo_header(struct seq_file *m);
78034 * for general use, and so are not documented here. For a full list of
78035 * potential flags, always refer to linux/gfp.h.
78036 */
78037 +
78038 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
78039 {
78040 if (size != 0 && n > SIZE_MAX / size)
78041 @@ -465,7 +489,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
78042 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
78043 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
78044 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
78045 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
78046 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
78047 #define kmalloc_track_caller(size, flags) \
78048 __kmalloc_track_caller(size, flags, _RET_IP_)
78049 #else
78050 @@ -485,7 +509,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
78051 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
78052 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
78053 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
78054 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
78055 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
78056 #define kmalloc_node_track_caller(size, flags, node) \
78057 __kmalloc_node_track_caller(size, flags, node, \
78058 _RET_IP_)
78059 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
78060 index cd40158..4e2f7af 100644
78061 --- a/include/linux/slab_def.h
78062 +++ b/include/linux/slab_def.h
78063 @@ -50,7 +50,7 @@ struct kmem_cache {
78064 /* 4) cache creation/removal */
78065 const char *name;
78066 struct list_head list;
78067 - int refcount;
78068 + atomic_t refcount;
78069 int object_size;
78070 int align;
78071
78072 @@ -66,10 +66,14 @@ struct kmem_cache {
78073 unsigned long node_allocs;
78074 unsigned long node_frees;
78075 unsigned long node_overflow;
78076 - atomic_t allochit;
78077 - atomic_t allocmiss;
78078 - atomic_t freehit;
78079 - atomic_t freemiss;
78080 + atomic_unchecked_t allochit;
78081 + atomic_unchecked_t allocmiss;
78082 + atomic_unchecked_t freehit;
78083 + atomic_unchecked_t freemiss;
78084 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78085 + atomic_unchecked_t sanitized;
78086 + atomic_unchecked_t not_sanitized;
78087 +#endif
78088
78089 /*
78090 * If debugging is enabled, then the allocator can add additional
78091 @@ -103,7 +107,7 @@ struct kmem_cache {
78092 };
78093
78094 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
78095 -void *__kmalloc(size_t size, gfp_t flags);
78096 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
78097
78098 #ifdef CONFIG_TRACING
78099 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
78100 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
78101 cachep = kmalloc_dma_caches[i];
78102 else
78103 #endif
78104 +
78105 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78106 + if (flags & GFP_USERCOPY)
78107 + cachep = kmalloc_usercopy_caches[i];
78108 + else
78109 +#endif
78110 +
78111 cachep = kmalloc_caches[i];
78112
78113 ret = kmem_cache_alloc_trace(cachep, flags, size);
78114 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
78115 }
78116
78117 #ifdef CONFIG_NUMA
78118 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
78119 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
78120 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
78121
78122 #ifdef CONFIG_TRACING
78123 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
78124 cachep = kmalloc_dma_caches[i];
78125 else
78126 #endif
78127 +
78128 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78129 + if (flags & GFP_USERCOPY)
78130 + cachep = kmalloc_usercopy_caches[i];
78131 + else
78132 +#endif
78133 +
78134 cachep = kmalloc_caches[i];
78135
78136 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
78137 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
78138 index f28e14a..7831211 100644
78139 --- a/include/linux/slob_def.h
78140 +++ b/include/linux/slob_def.h
78141 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
78142 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
78143 }
78144
78145 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78146 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
78147
78148 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
78149 {
78150 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
78151 return __kmalloc_node(size, flags, NUMA_NO_NODE);
78152 }
78153
78154 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
78155 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
78156 {
78157 return kmalloc(size, flags);
78158 }
78159 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
78160 index 027276f..092bfe8 100644
78161 --- a/include/linux/slub_def.h
78162 +++ b/include/linux/slub_def.h
78163 @@ -80,7 +80,7 @@ struct kmem_cache {
78164 struct kmem_cache_order_objects max;
78165 struct kmem_cache_order_objects min;
78166 gfp_t allocflags; /* gfp flags to use on each alloc */
78167 - int refcount; /* Refcount for slab cache destroy */
78168 + atomic_t refcount; /* Refcount for slab cache destroy */
78169 void (*ctor)(void *);
78170 int inuse; /* Offset to metadata */
78171 int align; /* Alignment */
78172 @@ -105,7 +105,7 @@ struct kmem_cache {
78173 };
78174
78175 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
78176 -void *__kmalloc(size_t size, gfp_t flags);
78177 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
78178
78179 static __always_inline void *
78180 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
78181 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
78182 }
78183 #endif
78184
78185 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
78186 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
78187 {
78188 unsigned int order = get_order(size);
78189 return kmalloc_order_trace(size, flags, order);
78190 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
78191 }
78192
78193 #ifdef CONFIG_NUMA
78194 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78195 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
78196 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
78197
78198 #ifdef CONFIG_TRACING
78199 diff --git a/include/linux/smp.h b/include/linux/smp.h
78200 index c848876..11e8a84 100644
78201 --- a/include/linux/smp.h
78202 +++ b/include/linux/smp.h
78203 @@ -221,7 +221,9 @@ static inline void kick_all_cpus_sync(void) { }
78204 #endif
78205
78206 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
78207 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
78208 #define put_cpu() preempt_enable()
78209 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
78210
78211 /*
78212 * Callback to arch code if there's nosmp or maxcpus=0 on the
78213 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
78214 index 54f91d3..be2c379 100644
78215 --- a/include/linux/sock_diag.h
78216 +++ b/include/linux/sock_diag.h
78217 @@ -11,7 +11,7 @@ struct sock;
78218 struct sock_diag_handler {
78219 __u8 family;
78220 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
78221 -};
78222 +} __do_const;
78223
78224 int sock_diag_register(const struct sock_diag_handler *h);
78225 void sock_diag_unregister(const struct sock_diag_handler *h);
78226 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
78227 index 680f9a3..f13aeb0 100644
78228 --- a/include/linux/sonet.h
78229 +++ b/include/linux/sonet.h
78230 @@ -7,7 +7,7 @@
78231 #include <uapi/linux/sonet.h>
78232
78233 struct k_sonet_stats {
78234 -#define __HANDLE_ITEM(i) atomic_t i
78235 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
78236 __SONET_ITEMS
78237 #undef __HANDLE_ITEM
78238 };
78239 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
78240 index 07d8e53..dc934c9 100644
78241 --- a/include/linux/sunrpc/addr.h
78242 +++ b/include/linux/sunrpc/addr.h
78243 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
78244 {
78245 switch (sap->sa_family) {
78246 case AF_INET:
78247 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
78248 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
78249 case AF_INET6:
78250 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
78251 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
78252 }
78253 return 0;
78254 }
78255 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
78256 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
78257 const struct sockaddr *src)
78258 {
78259 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
78260 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
78261 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
78262
78263 dsin->sin_family = ssin->sin_family;
78264 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
78265 if (sa->sa_family != AF_INET6)
78266 return 0;
78267
78268 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
78269 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
78270 }
78271
78272 #endif /* _LINUX_SUNRPC_ADDR_H */
78273 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
78274 index bfe11be..12bc8c4 100644
78275 --- a/include/linux/sunrpc/clnt.h
78276 +++ b/include/linux/sunrpc/clnt.h
78277 @@ -96,7 +96,7 @@ struct rpc_procinfo {
78278 unsigned int p_timer; /* Which RTT timer to use */
78279 u32 p_statidx; /* Which procedure to account */
78280 const char * p_name; /* name of procedure */
78281 -};
78282 +} __do_const;
78283
78284 #ifdef __KERNEL__
78285
78286 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
78287 index 1f0216b..6a4fa50 100644
78288 --- a/include/linux/sunrpc/svc.h
78289 +++ b/include/linux/sunrpc/svc.h
78290 @@ -411,7 +411,7 @@ struct svc_procedure {
78291 unsigned int pc_count; /* call count */
78292 unsigned int pc_cachetype; /* cache info (NFS) */
78293 unsigned int pc_xdrressize; /* maximum size of XDR reply */
78294 -};
78295 +} __do_const;
78296
78297 /*
78298 * Function prototypes.
78299 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
78300 index 0b8e3e6..33e0a01 100644
78301 --- a/include/linux/sunrpc/svc_rdma.h
78302 +++ b/include/linux/sunrpc/svc_rdma.h
78303 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
78304 extern unsigned int svcrdma_max_requests;
78305 extern unsigned int svcrdma_max_req_size;
78306
78307 -extern atomic_t rdma_stat_recv;
78308 -extern atomic_t rdma_stat_read;
78309 -extern atomic_t rdma_stat_write;
78310 -extern atomic_t rdma_stat_sq_starve;
78311 -extern atomic_t rdma_stat_rq_starve;
78312 -extern atomic_t rdma_stat_rq_poll;
78313 -extern atomic_t rdma_stat_rq_prod;
78314 -extern atomic_t rdma_stat_sq_poll;
78315 -extern atomic_t rdma_stat_sq_prod;
78316 +extern atomic_unchecked_t rdma_stat_recv;
78317 +extern atomic_unchecked_t rdma_stat_read;
78318 +extern atomic_unchecked_t rdma_stat_write;
78319 +extern atomic_unchecked_t rdma_stat_sq_starve;
78320 +extern atomic_unchecked_t rdma_stat_rq_starve;
78321 +extern atomic_unchecked_t rdma_stat_rq_poll;
78322 +extern atomic_unchecked_t rdma_stat_rq_prod;
78323 +extern atomic_unchecked_t rdma_stat_sq_poll;
78324 +extern atomic_unchecked_t rdma_stat_sq_prod;
78325
78326 #define RPCRDMA_VERSION 1
78327
78328 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
78329 index ff374ab..7fd2ecb 100644
78330 --- a/include/linux/sunrpc/svcauth.h
78331 +++ b/include/linux/sunrpc/svcauth.h
78332 @@ -109,7 +109,7 @@ struct auth_ops {
78333 int (*release)(struct svc_rqst *rq);
78334 void (*domain_release)(struct auth_domain *);
78335 int (*set_client)(struct svc_rqst *rq);
78336 -};
78337 +} __do_const;
78338
78339 #define SVC_GARBAGE 1
78340 #define SVC_SYSERR 2
78341 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
78342 index a5ffd32..0935dea 100644
78343 --- a/include/linux/swiotlb.h
78344 +++ b/include/linux/swiotlb.h
78345 @@ -60,7 +60,8 @@ extern void
78346
78347 extern void
78348 swiotlb_free_coherent(struct device *hwdev, size_t size,
78349 - void *vaddr, dma_addr_t dma_handle);
78350 + void *vaddr, dma_addr_t dma_handle,
78351 + struct dma_attrs *attrs);
78352
78353 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
78354 unsigned long offset, size_t size,
78355 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
78356 index 84662ec..d8f8adb 100644
78357 --- a/include/linux/syscalls.h
78358 +++ b/include/linux/syscalls.h
78359 @@ -97,8 +97,12 @@ struct sigaltstack;
78360 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
78361
78362 #define __SC_DECL(t, a) t a
78363 -#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
78364 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
78365 +#define __TYPE_IS_SL(t) (__same_type((t)0, 0L))
78366 +#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
78367 +#define __TYPE_IS_SLL(t) (__same_type((t)0, 0LL))
78368 +#define __TYPE_IS_ULL(t) (__same_type((t)0, 0ULL))
78369 +#define __TYPE_IS_LL(t) (__TYPE_IS_SLL(t) || __TYPE_IS_ULL(t))
78370 +#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
78371 #define __SC_CAST(t, a) (t) a
78372 #define __SC_ARGS(t, a) a
78373 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
78374 @@ -362,11 +366,11 @@ asmlinkage long sys_sync(void);
78375 asmlinkage long sys_fsync(unsigned int fd);
78376 asmlinkage long sys_fdatasync(unsigned int fd);
78377 asmlinkage long sys_bdflush(int func, long data);
78378 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
78379 - char __user *type, unsigned long flags,
78380 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
78381 + const char __user *type, unsigned long flags,
78382 void __user *data);
78383 -asmlinkage long sys_umount(char __user *name, int flags);
78384 -asmlinkage long sys_oldumount(char __user *name);
78385 +asmlinkage long sys_umount(const char __user *name, int flags);
78386 +asmlinkage long sys_oldumount(const char __user *name);
78387 asmlinkage long sys_truncate(const char __user *path, long length);
78388 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
78389 asmlinkage long sys_stat(const char __user *filename,
78390 @@ -578,7 +582,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
78391 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
78392 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
78393 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
78394 - struct sockaddr __user *, int);
78395 + struct sockaddr __user *, int) __intentional_overflow(0);
78396 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
78397 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
78398 unsigned int vlen, unsigned flags);
78399 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
78400 index 27b3b0b..e093dd9 100644
78401 --- a/include/linux/syscore_ops.h
78402 +++ b/include/linux/syscore_ops.h
78403 @@ -16,7 +16,7 @@ struct syscore_ops {
78404 int (*suspend)(void);
78405 void (*resume)(void);
78406 void (*shutdown)(void);
78407 -};
78408 +} __do_const;
78409
78410 extern void register_syscore_ops(struct syscore_ops *ops);
78411 extern void unregister_syscore_ops(struct syscore_ops *ops);
78412 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
78413 index 14a8ff2..af52bad 100644
78414 --- a/include/linux/sysctl.h
78415 +++ b/include/linux/sysctl.h
78416 @@ -34,13 +34,13 @@ struct ctl_table_root;
78417 struct ctl_table_header;
78418 struct ctl_dir;
78419
78420 -typedef struct ctl_table ctl_table;
78421 -
78422 typedef int proc_handler (struct ctl_table *ctl, int write,
78423 void __user *buffer, size_t *lenp, loff_t *ppos);
78424
78425 extern int proc_dostring(struct ctl_table *, int,
78426 void __user *, size_t *, loff_t *);
78427 +extern int proc_dostring_modpriv(struct ctl_table *, int,
78428 + void __user *, size_t *, loff_t *);
78429 extern int proc_dointvec(struct ctl_table *, int,
78430 void __user *, size_t *, loff_t *);
78431 extern int proc_dointvec_minmax(struct ctl_table *, int,
78432 @@ -115,7 +115,9 @@ struct ctl_table
78433 struct ctl_table_poll *poll;
78434 void *extra1;
78435 void *extra2;
78436 -};
78437 +} __do_const;
78438 +typedef struct ctl_table __no_const ctl_table_no_const;
78439 +typedef struct ctl_table ctl_table;
78440
78441 struct ctl_node {
78442 struct rb_node node;
78443 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
78444 index e2cee22..3ddb921 100644
78445 --- a/include/linux/sysfs.h
78446 +++ b/include/linux/sysfs.h
78447 @@ -31,7 +31,8 @@ struct attribute {
78448 struct lock_class_key *key;
78449 struct lock_class_key skey;
78450 #endif
78451 -};
78452 +} __do_const;
78453 +typedef struct attribute __no_const attribute_no_const;
78454
78455 /**
78456 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78457 @@ -59,8 +60,8 @@ struct attribute_group {
78458 umode_t (*is_visible)(struct kobject *,
78459 struct attribute *, int);
78460 struct attribute **attrs;
78461 -};
78462 -
78463 +} __do_const;
78464 +typedef struct attribute_group __no_const attribute_group_no_const;
78465
78466
78467 /**
78468 @@ -107,7 +108,8 @@ struct bin_attribute {
78469 char *, loff_t, size_t);
78470 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78471 struct vm_area_struct *vma);
78472 -};
78473 +} __do_const;
78474 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78475
78476 /**
78477 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78478 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78479 index 7faf933..9b85a0c 100644
78480 --- a/include/linux/sysrq.h
78481 +++ b/include/linux/sysrq.h
78482 @@ -16,6 +16,7 @@
78483
78484 #include <linux/errno.h>
78485 #include <linux/types.h>
78486 +#include <linux/compiler.h>
78487
78488 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78489 #define SYSRQ_DEFAULT_ENABLE 1
78490 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78491 char *help_msg;
78492 char *action_msg;
78493 int enable_mask;
78494 -};
78495 +} __do_const;
78496
78497 #ifdef CONFIG_MAGIC_SYSRQ
78498
78499 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78500 index e7e0473..7989295 100644
78501 --- a/include/linux/thread_info.h
78502 +++ b/include/linux/thread_info.h
78503 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78504 #error "no set_restore_sigmask() provided and default one won't work"
78505 #endif
78506
78507 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78508 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78509 +{
78510 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78511 + if (!__builtin_constant_p(n))
78512 +#endif
78513 + __check_object_size(ptr, n, to_user);
78514 +}
78515 +
78516 #endif /* __KERNEL__ */
78517
78518 #endif /* _LINUX_THREAD_INFO_H */
78519 diff --git a/include/linux/tty.h b/include/linux/tty.h
78520 index 8780bd2..d1ae08b 100644
78521 --- a/include/linux/tty.h
78522 +++ b/include/linux/tty.h
78523 @@ -194,7 +194,7 @@ struct tty_port {
78524 const struct tty_port_operations *ops; /* Port operations */
78525 spinlock_t lock; /* Lock protecting tty field */
78526 int blocked_open; /* Waiting to open */
78527 - int count; /* Usage count */
78528 + atomic_t count; /* Usage count */
78529 wait_queue_head_t open_wait; /* Open waiters */
78530 wait_queue_head_t close_wait; /* Close waiters */
78531 wait_queue_head_t delta_msr_wait; /* Modem status change */
78532 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
78533 struct tty_struct *tty, struct file *filp);
78534 static inline int tty_port_users(struct tty_port *port)
78535 {
78536 - return port->count + port->blocked_open;
78537 + return atomic_read(&port->count) + port->blocked_open;
78538 }
78539
78540 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78541 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78542 index 756a609..b302dd6 100644
78543 --- a/include/linux/tty_driver.h
78544 +++ b/include/linux/tty_driver.h
78545 @@ -285,7 +285,7 @@ struct tty_operations {
78546 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78547 #endif
78548 const struct file_operations *proc_fops;
78549 -};
78550 +} __do_const;
78551
78552 struct tty_driver {
78553 int magic; /* magic number for this structure */
78554 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78555 index 58390c7..95e214c 100644
78556 --- a/include/linux/tty_ldisc.h
78557 +++ b/include/linux/tty_ldisc.h
78558 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
78559
78560 struct module *owner;
78561
78562 - int refcount;
78563 + atomic_t refcount;
78564 };
78565
78566 struct tty_ldisc {
78567 diff --git a/include/linux/types.h b/include/linux/types.h
78568 index 4d118ba..c3ee9bf 100644
78569 --- a/include/linux/types.h
78570 +++ b/include/linux/types.h
78571 @@ -176,10 +176,26 @@ typedef struct {
78572 int counter;
78573 } atomic_t;
78574
78575 +#ifdef CONFIG_PAX_REFCOUNT
78576 +typedef struct {
78577 + int counter;
78578 +} atomic_unchecked_t;
78579 +#else
78580 +typedef atomic_t atomic_unchecked_t;
78581 +#endif
78582 +
78583 #ifdef CONFIG_64BIT
78584 typedef struct {
78585 long counter;
78586 } atomic64_t;
78587 +
78588 +#ifdef CONFIG_PAX_REFCOUNT
78589 +typedef struct {
78590 + long counter;
78591 +} atomic64_unchecked_t;
78592 +#else
78593 +typedef atomic64_t atomic64_unchecked_t;
78594 +#endif
78595 #endif
78596
78597 struct list_head {
78598 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78599 index 5ca0951..ab496a5 100644
78600 --- a/include/linux/uaccess.h
78601 +++ b/include/linux/uaccess.h
78602 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78603 long ret; \
78604 mm_segment_t old_fs = get_fs(); \
78605 \
78606 - set_fs(KERNEL_DS); \
78607 pagefault_disable(); \
78608 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78609 - pagefault_enable(); \
78610 + set_fs(KERNEL_DS); \
78611 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78612 set_fs(old_fs); \
78613 + pagefault_enable(); \
78614 ret; \
78615 })
78616
78617 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78618 index 8e522cbc..aa8572d 100644
78619 --- a/include/linux/uidgid.h
78620 +++ b/include/linux/uidgid.h
78621 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78622
78623 #endif /* CONFIG_USER_NS */
78624
78625 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78626 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78627 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78628 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78629 +
78630 #endif /* _LINUX_UIDGID_H */
78631 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78632 index 99c1b4d..562e6f3 100644
78633 --- a/include/linux/unaligned/access_ok.h
78634 +++ b/include/linux/unaligned/access_ok.h
78635 @@ -4,34 +4,34 @@
78636 #include <linux/kernel.h>
78637 #include <asm/byteorder.h>
78638
78639 -static inline u16 get_unaligned_le16(const void *p)
78640 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78641 {
78642 - return le16_to_cpup((__le16 *)p);
78643 + return le16_to_cpup((const __le16 *)p);
78644 }
78645
78646 -static inline u32 get_unaligned_le32(const void *p)
78647 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78648 {
78649 - return le32_to_cpup((__le32 *)p);
78650 + return le32_to_cpup((const __le32 *)p);
78651 }
78652
78653 -static inline u64 get_unaligned_le64(const void *p)
78654 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78655 {
78656 - return le64_to_cpup((__le64 *)p);
78657 + return le64_to_cpup((const __le64 *)p);
78658 }
78659
78660 -static inline u16 get_unaligned_be16(const void *p)
78661 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78662 {
78663 - return be16_to_cpup((__be16 *)p);
78664 + return be16_to_cpup((const __be16 *)p);
78665 }
78666
78667 -static inline u32 get_unaligned_be32(const void *p)
78668 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78669 {
78670 - return be32_to_cpup((__be32 *)p);
78671 + return be32_to_cpup((const __be32 *)p);
78672 }
78673
78674 -static inline u64 get_unaligned_be64(const void *p)
78675 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78676 {
78677 - return be64_to_cpup((__be64 *)p);
78678 + return be64_to_cpup((const __be64 *)p);
78679 }
78680
78681 static inline void put_unaligned_le16(u16 val, void *p)
78682 diff --git a/include/linux/usb.h b/include/linux/usb.h
78683 index a0bee5a..5533a52 100644
78684 --- a/include/linux/usb.h
78685 +++ b/include/linux/usb.h
78686 @@ -552,7 +552,7 @@ struct usb_device {
78687 int maxchild;
78688
78689 u32 quirks;
78690 - atomic_t urbnum;
78691 + atomic_unchecked_t urbnum;
78692
78693 unsigned long active_duration;
78694
78695 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78696
78697 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78698 __u8 request, __u8 requesttype, __u16 value, __u16 index,
78699 - void *data, __u16 size, int timeout);
78700 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
78701 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
78702 void *data, int len, int *actual_length, int timeout);
78703 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
78704 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
78705 index e452ba6..78f8e80 100644
78706 --- a/include/linux/usb/renesas_usbhs.h
78707 +++ b/include/linux/usb/renesas_usbhs.h
78708 @@ -39,7 +39,7 @@ enum {
78709 */
78710 struct renesas_usbhs_driver_callback {
78711 int (*notify_hotplug)(struct platform_device *pdev);
78712 -};
78713 +} __no_const;
78714
78715 /*
78716 * callback functions for platform
78717 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
78718 index 6f8fbcf..8259001 100644
78719 --- a/include/linux/vermagic.h
78720 +++ b/include/linux/vermagic.h
78721 @@ -25,9 +25,35 @@
78722 #define MODULE_ARCH_VERMAGIC ""
78723 #endif
78724
78725 +#ifdef CONFIG_PAX_REFCOUNT
78726 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
78727 +#else
78728 +#define MODULE_PAX_REFCOUNT ""
78729 +#endif
78730 +
78731 +#ifdef CONSTIFY_PLUGIN
78732 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
78733 +#else
78734 +#define MODULE_CONSTIFY_PLUGIN ""
78735 +#endif
78736 +
78737 +#ifdef STACKLEAK_PLUGIN
78738 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
78739 +#else
78740 +#define MODULE_STACKLEAK_PLUGIN ""
78741 +#endif
78742 +
78743 +#ifdef CONFIG_GRKERNSEC
78744 +#define MODULE_GRSEC "GRSEC "
78745 +#else
78746 +#define MODULE_GRSEC ""
78747 +#endif
78748 +
78749 #define VERMAGIC_STRING \
78750 UTS_RELEASE " " \
78751 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
78752 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
78753 - MODULE_ARCH_VERMAGIC
78754 + MODULE_ARCH_VERMAGIC \
78755 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
78756 + MODULE_GRSEC
78757
78758 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
78759 index 7d5773a..541c01c 100644
78760 --- a/include/linux/vmalloc.h
78761 +++ b/include/linux/vmalloc.h
78762 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
78763 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
78764 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
78765 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
78766 +
78767 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
78768 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
78769 +#endif
78770 +
78771 /* bits [20..32] reserved for arch specific ioremap internals */
78772
78773 /*
78774 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
78775 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
78776 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
78777 unsigned long start, unsigned long end, gfp_t gfp_mask,
78778 - pgprot_t prot, int node, const void *caller);
78779 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
78780 extern void vfree(const void *addr);
78781
78782 extern void *vmap(struct page **pages, unsigned int count,
78783 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
78784 extern void free_vm_area(struct vm_struct *area);
78785
78786 /* for /dev/kmem */
78787 -extern long vread(char *buf, char *addr, unsigned long count);
78788 -extern long vwrite(char *buf, char *addr, unsigned long count);
78789 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
78790 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
78791
78792 /*
78793 * Internals. Dont't use..
78794 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
78795 index c586679..f06b389 100644
78796 --- a/include/linux/vmstat.h
78797 +++ b/include/linux/vmstat.h
78798 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
78799 /*
78800 * Zone based page accounting with per cpu differentials.
78801 */
78802 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78803 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78804
78805 static inline void zone_page_state_add(long x, struct zone *zone,
78806 enum zone_stat_item item)
78807 {
78808 - atomic_long_add(x, &zone->vm_stat[item]);
78809 - atomic_long_add(x, &vm_stat[item]);
78810 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
78811 + atomic_long_add_unchecked(x, &vm_stat[item]);
78812 }
78813
78814 static inline unsigned long global_page_state(enum zone_stat_item item)
78815 {
78816 - long x = atomic_long_read(&vm_stat[item]);
78817 + long x = atomic_long_read_unchecked(&vm_stat[item]);
78818 #ifdef CONFIG_SMP
78819 if (x < 0)
78820 x = 0;
78821 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
78822 static inline unsigned long zone_page_state(struct zone *zone,
78823 enum zone_stat_item item)
78824 {
78825 - long x = atomic_long_read(&zone->vm_stat[item]);
78826 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78827 #ifdef CONFIG_SMP
78828 if (x < 0)
78829 x = 0;
78830 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
78831 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
78832 enum zone_stat_item item)
78833 {
78834 - long x = atomic_long_read(&zone->vm_stat[item]);
78835 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78836
78837 #ifdef CONFIG_SMP
78838 int cpu;
78839 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
78840
78841 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
78842 {
78843 - atomic_long_inc(&zone->vm_stat[item]);
78844 - atomic_long_inc(&vm_stat[item]);
78845 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
78846 + atomic_long_inc_unchecked(&vm_stat[item]);
78847 }
78848
78849 static inline void __inc_zone_page_state(struct page *page,
78850 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
78851
78852 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
78853 {
78854 - atomic_long_dec(&zone->vm_stat[item]);
78855 - atomic_long_dec(&vm_stat[item]);
78856 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
78857 + atomic_long_dec_unchecked(&vm_stat[item]);
78858 }
78859
78860 static inline void __dec_zone_page_state(struct page *page,
78861 diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
78862 index 623488f..44b5742 100644
78863 --- a/include/linux/workqueue.h
78864 +++ b/include/linux/workqueue.h
78865 @@ -410,11 +410,11 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
78866 alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
78867
78868 #define create_workqueue(name) \
78869 - alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
78870 + alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, (name))
78871 #define create_freezable_workqueue(name) \
78872 - alloc_workqueue((name), WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
78873 + alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
78874 #define create_singlethread_workqueue(name) \
78875 - alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
78876 + alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
78877
78878 extern void destroy_workqueue(struct workqueue_struct *wq);
78879
78880 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
78881 index fdbafc6..49dfe4f 100644
78882 --- a/include/linux/xattr.h
78883 +++ b/include/linux/xattr.h
78884 @@ -28,7 +28,7 @@ struct xattr_handler {
78885 size_t size, int handler_flags);
78886 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
78887 size_t size, int flags, int handler_flags);
78888 -};
78889 +} __do_const;
78890
78891 struct xattr {
78892 char *name;
78893 @@ -37,6 +37,9 @@ struct xattr {
78894 };
78895
78896 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
78897 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
78898 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
78899 +#endif
78900 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
78901 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
78902 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
78903 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
78904 index 9c5a6b4..09c9438 100644
78905 --- a/include/linux/zlib.h
78906 +++ b/include/linux/zlib.h
78907 @@ -31,6 +31,7 @@
78908 #define _ZLIB_H
78909
78910 #include <linux/zconf.h>
78911 +#include <linux/compiler.h>
78912
78913 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
78914 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
78915 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
78916
78917 /* basic functions */
78918
78919 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
78920 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
78921 /*
78922 Returns the number of bytes that needs to be allocated for a per-
78923 stream workspace with the specified parameters. A pointer to this
78924 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
78925 index 95d1c91..6798cca 100644
78926 --- a/include/media/v4l2-dev.h
78927 +++ b/include/media/v4l2-dev.h
78928 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
78929 int (*mmap) (struct file *, struct vm_area_struct *);
78930 int (*open) (struct file *);
78931 int (*release) (struct file *);
78932 -};
78933 +} __do_const;
78934
78935 /*
78936 * Newer version of video_device, handled by videodev2.c
78937 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
78938 index c9b1593..a572459 100644
78939 --- a/include/media/v4l2-device.h
78940 +++ b/include/media/v4l2-device.h
78941 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
78942 this function returns 0. If the name ends with a digit (e.g. cx18),
78943 then the name will be set to cx18-0 since cx180 looks really odd. */
78944 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
78945 - atomic_t *instance);
78946 + atomic_unchecked_t *instance);
78947
78948 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
78949 Since the parent disappears this ensures that v4l2_dev doesn't have an
78950 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
78951 index adcbb20..62c2559 100644
78952 --- a/include/net/9p/transport.h
78953 +++ b/include/net/9p/transport.h
78954 @@ -57,7 +57,7 @@ struct p9_trans_module {
78955 int (*cancel) (struct p9_client *, struct p9_req_t *req);
78956 int (*zc_request)(struct p9_client *, struct p9_req_t *,
78957 char *, char *, int , int, int, int);
78958 -};
78959 +} __do_const;
78960
78961 void v9fs_register_trans(struct p9_trans_module *m);
78962 void v9fs_unregister_trans(struct p9_trans_module *m);
78963 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
78964 index fb94cf1..7c0c987 100644
78965 --- a/include/net/bluetooth/l2cap.h
78966 +++ b/include/net/bluetooth/l2cap.h
78967 @@ -551,7 +551,7 @@ struct l2cap_ops {
78968 void (*defer) (struct l2cap_chan *chan);
78969 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
78970 unsigned long len, int nb);
78971 -};
78972 +} __do_const;
78973
78974 struct l2cap_conn {
78975 struct hci_conn *hcon;
78976 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
78977 index f2ae33d..c457cf0 100644
78978 --- a/include/net/caif/cfctrl.h
78979 +++ b/include/net/caif/cfctrl.h
78980 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
78981 void (*radioset_rsp)(void);
78982 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
78983 struct cflayer *client_layer);
78984 -};
78985 +} __no_const;
78986
78987 /* Link Setup Parameters for CAIF-Links. */
78988 struct cfctrl_link_param {
78989 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
78990 struct cfctrl {
78991 struct cfsrvl serv;
78992 struct cfctrl_rsp res;
78993 - atomic_t req_seq_no;
78994 - atomic_t rsp_seq_no;
78995 + atomic_unchecked_t req_seq_no;
78996 + atomic_unchecked_t rsp_seq_no;
78997 struct list_head list;
78998 /* Protects from simultaneous access to first_req list */
78999 spinlock_t info_list_lock;
79000 diff --git a/include/net/flow.h b/include/net/flow.h
79001 index 628e11b..4c475df 100644
79002 --- a/include/net/flow.h
79003 +++ b/include/net/flow.h
79004 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
79005
79006 extern void flow_cache_flush(void);
79007 extern void flow_cache_flush_deferred(void);
79008 -extern atomic_t flow_cache_genid;
79009 +extern atomic_unchecked_t flow_cache_genid;
79010
79011 #endif
79012 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
79013 index 93024a4..eeb6b6e 100644
79014 --- a/include/net/genetlink.h
79015 +++ b/include/net/genetlink.h
79016 @@ -119,7 +119,7 @@ struct genl_ops {
79017 struct netlink_callback *cb);
79018 int (*done)(struct netlink_callback *cb);
79019 struct list_head ops_list;
79020 -};
79021 +} __do_const;
79022
79023 extern int genl_register_family(struct genl_family *family);
79024 extern int genl_register_family_with_ops(struct genl_family *family,
79025 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
79026 index 734d9b5..48a9a4b 100644
79027 --- a/include/net/gro_cells.h
79028 +++ b/include/net/gro_cells.h
79029 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
79030 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
79031
79032 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
79033 - atomic_long_inc(&dev->rx_dropped);
79034 + atomic_long_inc_unchecked(&dev->rx_dropped);
79035 kfree_skb(skb);
79036 return;
79037 }
79038 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
79039 index de2c785..0588a6b 100644
79040 --- a/include/net/inet_connection_sock.h
79041 +++ b/include/net/inet_connection_sock.h
79042 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
79043 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
79044 int (*bind_conflict)(const struct sock *sk,
79045 const struct inet_bind_bucket *tb, bool relax);
79046 -};
79047 +} __do_const;
79048
79049 /** inet_connection_sock - INET connection oriented sock
79050 *
79051 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
79052 index 53f464d..0bd0b49 100644
79053 --- a/include/net/inetpeer.h
79054 +++ b/include/net/inetpeer.h
79055 @@ -47,8 +47,8 @@ struct inet_peer {
79056 */
79057 union {
79058 struct {
79059 - atomic_t rid; /* Frag reception counter */
79060 - atomic_t ip_id_count; /* IP ID for the next packet */
79061 + atomic_unchecked_t rid; /* Frag reception counter */
79062 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
79063 };
79064 struct rcu_head rcu;
79065 struct inet_peer *gc_next;
79066 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
79067 /* can be called with or without local BH being disabled */
79068 static inline int inet_getid(struct inet_peer *p, int more)
79069 {
79070 - int old, new;
79071 + int id;
79072 more++;
79073 inet_peer_refcheck(p);
79074 - do {
79075 - old = atomic_read(&p->ip_id_count);
79076 - new = old + more;
79077 - if (!new)
79078 - new = 1;
79079 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
79080 - return new;
79081 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
79082 + if (!id)
79083 + id = atomic_inc_return_unchecked(&p->ip_id_count);
79084 + return id;
79085 }
79086
79087 #endif /* _NET_INETPEER_H */
79088 diff --git a/include/net/ip.h b/include/net/ip.h
79089 index a68f838..74518ab 100644
79090 --- a/include/net/ip.h
79091 +++ b/include/net/ip.h
79092 @@ -202,7 +202,7 @@ extern struct local_ports {
79093 } sysctl_local_ports;
79094 extern void inet_get_local_port_range(int *low, int *high);
79095
79096 -extern unsigned long *sysctl_local_reserved_ports;
79097 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
79098 static inline int inet_is_reserved_local_port(int port)
79099 {
79100 return test_bit(port, sysctl_local_reserved_ports);
79101 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
79102 index e49db91..76a81de 100644
79103 --- a/include/net/ip_fib.h
79104 +++ b/include/net/ip_fib.h
79105 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
79106
79107 #define FIB_RES_SADDR(net, res) \
79108 ((FIB_RES_NH(res).nh_saddr_genid == \
79109 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
79110 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
79111 FIB_RES_NH(res).nh_saddr : \
79112 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
79113 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
79114 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
79115 index 4c062cc..3562c31 100644
79116 --- a/include/net/ip_vs.h
79117 +++ b/include/net/ip_vs.h
79118 @@ -612,7 +612,7 @@ struct ip_vs_conn {
79119 struct ip_vs_conn *control; /* Master control connection */
79120 atomic_t n_control; /* Number of controlled ones */
79121 struct ip_vs_dest *dest; /* real server */
79122 - atomic_t in_pkts; /* incoming packet counter */
79123 + atomic_unchecked_t in_pkts; /* incoming packet counter */
79124
79125 /* packet transmitter for different forwarding methods. If it
79126 mangles the packet, it must return NF_DROP or better NF_STOLEN,
79127 @@ -761,7 +761,7 @@ struct ip_vs_dest {
79128 __be16 port; /* port number of the server */
79129 union nf_inet_addr addr; /* IP address of the server */
79130 volatile unsigned int flags; /* dest status flags */
79131 - atomic_t conn_flags; /* flags to copy to conn */
79132 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
79133 atomic_t weight; /* server weight */
79134
79135 atomic_t refcnt; /* reference counter */
79136 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
79137 /* ip_vs_lblc */
79138 int sysctl_lblc_expiration;
79139 struct ctl_table_header *lblc_ctl_header;
79140 - struct ctl_table *lblc_ctl_table;
79141 + ctl_table_no_const *lblc_ctl_table;
79142 /* ip_vs_lblcr */
79143 int sysctl_lblcr_expiration;
79144 struct ctl_table_header *lblcr_ctl_header;
79145 - struct ctl_table *lblcr_ctl_table;
79146 + ctl_table_no_const *lblcr_ctl_table;
79147 /* ip_vs_est */
79148 struct list_head est_list; /* estimator list */
79149 spinlock_t est_lock;
79150 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
79151 index 80ffde3..968b0f4 100644
79152 --- a/include/net/irda/ircomm_tty.h
79153 +++ b/include/net/irda/ircomm_tty.h
79154 @@ -35,6 +35,7 @@
79155 #include <linux/termios.h>
79156 #include <linux/timer.h>
79157 #include <linux/tty.h> /* struct tty_struct */
79158 +#include <asm/local.h>
79159
79160 #include <net/irda/irias_object.h>
79161 #include <net/irda/ircomm_core.h>
79162 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
79163 index 714cc9a..ea05f3e 100644
79164 --- a/include/net/iucv/af_iucv.h
79165 +++ b/include/net/iucv/af_iucv.h
79166 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
79167 struct iucv_sock_list {
79168 struct hlist_head head;
79169 rwlock_t lock;
79170 - atomic_t autobind_name;
79171 + atomic_unchecked_t autobind_name;
79172 };
79173
79174 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
79175 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
79176 index df83f69..9b640b8 100644
79177 --- a/include/net/llc_c_ac.h
79178 +++ b/include/net/llc_c_ac.h
79179 @@ -87,7 +87,7 @@
79180 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
79181 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
79182
79183 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79184 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79185
79186 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
79187 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
79188 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
79189 index 6ca3113..f8026dd 100644
79190 --- a/include/net/llc_c_ev.h
79191 +++ b/include/net/llc_c_ev.h
79192 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
79193 return (struct llc_conn_state_ev *)skb->cb;
79194 }
79195
79196 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79197 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79198 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79199 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79200
79201 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
79202 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
79203 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
79204 index 0e79cfb..f46db31 100644
79205 --- a/include/net/llc_c_st.h
79206 +++ b/include/net/llc_c_st.h
79207 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
79208 u8 next_state;
79209 llc_conn_ev_qfyr_t *ev_qualifiers;
79210 llc_conn_action_t *ev_actions;
79211 -};
79212 +} __do_const;
79213
79214 struct llc_conn_state {
79215 u8 current_state;
79216 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
79217 index 37a3bbd..55a4241 100644
79218 --- a/include/net/llc_s_ac.h
79219 +++ b/include/net/llc_s_ac.h
79220 @@ -23,7 +23,7 @@
79221 #define SAP_ACT_TEST_IND 9
79222
79223 /* All action functions must look like this */
79224 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79225 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79226
79227 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
79228 struct sk_buff *skb);
79229 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
79230 index 567c681..cd73ac0 100644
79231 --- a/include/net/llc_s_st.h
79232 +++ b/include/net/llc_s_st.h
79233 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
79234 llc_sap_ev_t ev;
79235 u8 next_state;
79236 llc_sap_action_t *ev_actions;
79237 -};
79238 +} __do_const;
79239
79240 struct llc_sap_state {
79241 u8 curr_state;
79242 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
79243 index 885898a..cdace34 100644
79244 --- a/include/net/mac80211.h
79245 +++ b/include/net/mac80211.h
79246 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
79247 void (*add_sta_debugfs)(void *priv, void *priv_sta,
79248 struct dentry *dir);
79249 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
79250 -};
79251 +} __do_const;
79252
79253 static inline int rate_supported(struct ieee80211_sta *sta,
79254 enum ieee80211_band band,
79255 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
79256 index 7e748ad..5c6229b 100644
79257 --- a/include/net/neighbour.h
79258 +++ b/include/net/neighbour.h
79259 @@ -123,7 +123,7 @@ struct neigh_ops {
79260 void (*error_report)(struct neighbour *, struct sk_buff *);
79261 int (*output)(struct neighbour *, struct sk_buff *);
79262 int (*connected_output)(struct neighbour *, struct sk_buff *);
79263 -};
79264 +} __do_const;
79265
79266 struct pneigh_entry {
79267 struct pneigh_entry *next;
79268 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
79269 index b176978..ea169f4 100644
79270 --- a/include/net/net_namespace.h
79271 +++ b/include/net/net_namespace.h
79272 @@ -117,7 +117,7 @@ struct net {
79273 #endif
79274 struct netns_ipvs *ipvs;
79275 struct sock *diag_nlsk;
79276 - atomic_t rt_genid;
79277 + atomic_unchecked_t rt_genid;
79278 };
79279
79280 /*
79281 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
79282 #define __net_init __init
79283 #define __net_exit __exit_refok
79284 #define __net_initdata __initdata
79285 +#ifdef CONSTIFY_PLUGIN
79286 #define __net_initconst __initconst
79287 +#else
79288 +#define __net_initconst __initdata
79289 +#endif
79290 #endif
79291
79292 struct pernet_operations {
79293 @@ -284,7 +288,7 @@ struct pernet_operations {
79294 void (*exit_batch)(struct list_head *net_exit_list);
79295 int *id;
79296 size_t size;
79297 -};
79298 +} __do_const;
79299
79300 /*
79301 * Use these carefully. If you implement a network device and it
79302 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
79303
79304 static inline int rt_genid(struct net *net)
79305 {
79306 - return atomic_read(&net->rt_genid);
79307 + return atomic_read_unchecked(&net->rt_genid);
79308 }
79309
79310 static inline void rt_genid_bump(struct net *net)
79311 {
79312 - atomic_inc(&net->rt_genid);
79313 + atomic_inc_unchecked(&net->rt_genid);
79314 }
79315
79316 #endif /* __NET_NET_NAMESPACE_H */
79317 diff --git a/include/net/netdma.h b/include/net/netdma.h
79318 index 8ba8ce2..99b7fff 100644
79319 --- a/include/net/netdma.h
79320 +++ b/include/net/netdma.h
79321 @@ -24,7 +24,7 @@
79322 #include <linux/dmaengine.h>
79323 #include <linux/skbuff.h>
79324
79325 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79326 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79327 struct sk_buff *skb, int offset, struct iovec *to,
79328 size_t len, struct dma_pinned_list *pinned_list);
79329
79330 diff --git a/include/net/netlink.h b/include/net/netlink.h
79331 index 9690b0f..87aded7 100644
79332 --- a/include/net/netlink.h
79333 +++ b/include/net/netlink.h
79334 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
79335 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
79336 {
79337 if (mark)
79338 - skb_trim(skb, (unsigned char *) mark - skb->data);
79339 + skb_trim(skb, (const unsigned char *) mark - skb->data);
79340 }
79341
79342 /**
79343 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
79344 index c9c0c53..53f24c3 100644
79345 --- a/include/net/netns/conntrack.h
79346 +++ b/include/net/netns/conntrack.h
79347 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
79348 struct nf_proto_net {
79349 #ifdef CONFIG_SYSCTL
79350 struct ctl_table_header *ctl_table_header;
79351 - struct ctl_table *ctl_table;
79352 + ctl_table_no_const *ctl_table;
79353 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
79354 struct ctl_table_header *ctl_compat_header;
79355 - struct ctl_table *ctl_compat_table;
79356 + ctl_table_no_const *ctl_compat_table;
79357 #endif
79358 #endif
79359 unsigned int users;
79360 @@ -58,7 +58,7 @@ struct nf_ip_net {
79361 struct nf_icmp_net icmpv6;
79362 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
79363 struct ctl_table_header *ctl_table_header;
79364 - struct ctl_table *ctl_table;
79365 + ctl_table_no_const *ctl_table;
79366 #endif
79367 };
79368
79369 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
79370 index 2ba9de8..47bd6c7 100644
79371 --- a/include/net/netns/ipv4.h
79372 +++ b/include/net/netns/ipv4.h
79373 @@ -67,7 +67,7 @@ struct netns_ipv4 {
79374 kgid_t sysctl_ping_group_range[2];
79375 long sysctl_tcp_mem[3];
79376
79377 - atomic_t dev_addr_genid;
79378 + atomic_unchecked_t dev_addr_genid;
79379
79380 #ifdef CONFIG_IP_MROUTE
79381 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
79382 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
79383 index 005e2c2..023d340 100644
79384 --- a/include/net/netns/ipv6.h
79385 +++ b/include/net/netns/ipv6.h
79386 @@ -71,7 +71,7 @@ struct netns_ipv6 {
79387 struct fib_rules_ops *mr6_rules_ops;
79388 #endif
79389 #endif
79390 - atomic_t dev_addr_genid;
79391 + atomic_unchecked_t dev_addr_genid;
79392 };
79393
79394 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
79395 diff --git a/include/net/protocol.h b/include/net/protocol.h
79396 index 047c047..b9dad15 100644
79397 --- a/include/net/protocol.h
79398 +++ b/include/net/protocol.h
79399 @@ -44,7 +44,7 @@ struct net_protocol {
79400 void (*err_handler)(struct sk_buff *skb, u32 info);
79401 unsigned int no_policy:1,
79402 netns_ok:1;
79403 -};
79404 +} __do_const;
79405
79406 #if IS_ENABLED(CONFIG_IPV6)
79407 struct inet6_protocol {
79408 @@ -57,7 +57,7 @@ struct inet6_protocol {
79409 u8 type, u8 code, int offset,
79410 __be32 info);
79411 unsigned int flags; /* INET6_PROTO_xxx */
79412 -};
79413 +} __do_const;
79414
79415 #define INET6_PROTO_NOPOLICY 0x1
79416 #define INET6_PROTO_FINAL 0x2
79417 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79418 index 7026648..584cc8c 100644
79419 --- a/include/net/rtnetlink.h
79420 +++ b/include/net/rtnetlink.h
79421 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79422 const struct net_device *dev);
79423 unsigned int (*get_num_tx_queues)(void);
79424 unsigned int (*get_num_rx_queues)(void);
79425 -};
79426 +} __do_const;
79427
79428 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79429 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79430 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
79431 index cd89510..d67810f 100644
79432 --- a/include/net/sctp/sctp.h
79433 +++ b/include/net/sctp/sctp.h
79434 @@ -330,9 +330,9 @@ do { \
79435
79436 #else /* SCTP_DEBUG */
79437
79438 -#define SCTP_DEBUG_PRINTK(whatever...)
79439 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
79440 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
79441 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
79442 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
79443 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
79444 #define SCTP_ENABLE_DEBUG
79445 #define SCTP_DISABLE_DEBUG
79446 #define SCTP_ASSERT(expr, str, func)
79447 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79448 index 2a82d13..62a31c2 100644
79449 --- a/include/net/sctp/sm.h
79450 +++ b/include/net/sctp/sm.h
79451 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79452 typedef struct {
79453 sctp_state_fn_t *fn;
79454 const char *name;
79455 -} sctp_sm_table_entry_t;
79456 +} __do_const sctp_sm_table_entry_t;
79457
79458 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79459 * currently in use.
79460 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79461 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79462
79463 /* Extern declarations for major data structures. */
79464 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79465 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79466
79467
79468 /* Get the size of a DATA chunk payload. */
79469 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79470 index 1bd4c41..9250b5b 100644
79471 --- a/include/net/sctp/structs.h
79472 +++ b/include/net/sctp/structs.h
79473 @@ -516,7 +516,7 @@ struct sctp_pf {
79474 struct sctp_association *asoc);
79475 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79476 struct sctp_af *af;
79477 -};
79478 +} __do_const;
79479
79480
79481 /* Structure to track chunk fragments that have been acked, but peer
79482 diff --git a/include/net/sock.h b/include/net/sock.h
79483 index 66772cf..25bc45b 100644
79484 --- a/include/net/sock.h
79485 +++ b/include/net/sock.h
79486 @@ -325,7 +325,7 @@ struct sock {
79487 #ifdef CONFIG_RPS
79488 __u32 sk_rxhash;
79489 #endif
79490 - atomic_t sk_drops;
79491 + atomic_unchecked_t sk_drops;
79492 int sk_rcvbuf;
79493
79494 struct sk_filter __rcu *sk_filter;
79495 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79496 }
79497
79498 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79499 - char __user *from, char *to,
79500 + char __user *from, unsigned char *to,
79501 int copy, int offset)
79502 {
79503 if (skb->ip_summed == CHECKSUM_NONE) {
79504 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79505 }
79506 }
79507
79508 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79509 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79510
79511 /**
79512 * sk_page_frag - return an appropriate page_frag
79513 diff --git a/include/net/tcp.h b/include/net/tcp.h
79514 index 5bba80f..8520a82 100644
79515 --- a/include/net/tcp.h
79516 +++ b/include/net/tcp.h
79517 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79518 extern void tcp_xmit_retransmit_queue(struct sock *);
79519 extern void tcp_simple_retransmit(struct sock *);
79520 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79521 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79522 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79523
79524 extern void tcp_send_probe0(struct sock *);
79525 extern void tcp_send_partial(struct sock *);
79526 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
79527 struct inet6_skb_parm h6;
79528 #endif
79529 } header; /* For incoming frames */
79530 - __u32 seq; /* Starting sequence number */
79531 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79532 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79533 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79534 __u32 when; /* used to compute rtt's */
79535 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79536
79537 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
79538
79539 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79540 /* 1 byte hole */
79541 - __u32 ack_seq; /* Sequence number ACK'd */
79542 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79543 };
79544
79545 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79546 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79547 index 94ce082..62b278d 100644
79548 --- a/include/net/xfrm.h
79549 +++ b/include/net/xfrm.h
79550 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
79551 struct net_device *dev,
79552 const struct flowi *fl);
79553 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79554 -};
79555 +} __do_const;
79556
79557 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79558 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79559 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
79560 struct sk_buff *skb);
79561 int (*transport_finish)(struct sk_buff *skb,
79562 int async);
79563 -};
79564 +} __do_const;
79565
79566 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79567 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79568 @@ -424,7 +424,7 @@ struct xfrm_mode {
79569 struct module *owner;
79570 unsigned int encap;
79571 int flags;
79572 -};
79573 +} __do_const;
79574
79575 /* Flags for xfrm_mode. */
79576 enum {
79577 @@ -521,7 +521,7 @@ struct xfrm_policy {
79578 struct timer_list timer;
79579
79580 struct flow_cache_object flo;
79581 - atomic_t genid;
79582 + atomic_unchecked_t genid;
79583 u32 priority;
79584 u32 index;
79585 struct xfrm_mark mark;
79586 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79587 index 1a046b1..ee0bef0 100644
79588 --- a/include/rdma/iw_cm.h
79589 +++ b/include/rdma/iw_cm.h
79590 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79591 int backlog);
79592
79593 int (*destroy_listen)(struct iw_cm_id *cm_id);
79594 -};
79595 +} __no_const;
79596
79597 /**
79598 * iw_create_cm_id - Create an IW CM identifier.
79599 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79600 index e1379b4..67eafbe 100644
79601 --- a/include/scsi/libfc.h
79602 +++ b/include/scsi/libfc.h
79603 @@ -762,6 +762,7 @@ struct libfc_function_template {
79604 */
79605 void (*disc_stop_final) (struct fc_lport *);
79606 };
79607 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79608
79609 /**
79610 * struct fc_disc - Discovery context
79611 @@ -866,7 +867,7 @@ struct fc_lport {
79612 struct fc_vport *vport;
79613
79614 /* Operational Information */
79615 - struct libfc_function_template tt;
79616 + libfc_function_template_no_const tt;
79617 u8 link_up;
79618 u8 qfull;
79619 enum fc_lport_state state;
79620 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79621 index cc64587..608f523 100644
79622 --- a/include/scsi/scsi_device.h
79623 +++ b/include/scsi/scsi_device.h
79624 @@ -171,9 +171,9 @@ struct scsi_device {
79625 unsigned int max_device_blocked; /* what device_blocked counts down from */
79626 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79627
79628 - atomic_t iorequest_cnt;
79629 - atomic_t iodone_cnt;
79630 - atomic_t ioerr_cnt;
79631 + atomic_unchecked_t iorequest_cnt;
79632 + atomic_unchecked_t iodone_cnt;
79633 + atomic_unchecked_t ioerr_cnt;
79634
79635 struct device sdev_gendev,
79636 sdev_dev;
79637 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
79638 index b797e8f..8e2c3aa 100644
79639 --- a/include/scsi/scsi_transport_fc.h
79640 +++ b/include/scsi/scsi_transport_fc.h
79641 @@ -751,7 +751,8 @@ struct fc_function_template {
79642 unsigned long show_host_system_hostname:1;
79643
79644 unsigned long disable_target_scan:1;
79645 -};
79646 +} __do_const;
79647 +typedef struct fc_function_template __no_const fc_function_template_no_const;
79648
79649
79650 /**
79651 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
79652 index 9031a26..750d592 100644
79653 --- a/include/sound/compress_driver.h
79654 +++ b/include/sound/compress_driver.h
79655 @@ -128,7 +128,7 @@ struct snd_compr_ops {
79656 struct snd_compr_caps *caps);
79657 int (*get_codec_caps) (struct snd_compr_stream *stream,
79658 struct snd_compr_codec_caps *codec);
79659 -};
79660 +} __no_const;
79661
79662 /**
79663 * struct snd_compr: Compressed device
79664 diff --git a/include/sound/soc.h b/include/sound/soc.h
79665 index 85c1522..f44bad1 100644
79666 --- a/include/sound/soc.h
79667 +++ b/include/sound/soc.h
79668 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
79669 /* probe ordering - for components with runtime dependencies */
79670 int probe_order;
79671 int remove_order;
79672 -};
79673 +} __do_const;
79674
79675 /* SoC platform interface */
79676 struct snd_soc_platform_driver {
79677 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
79678 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
79679 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
79680 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
79681 -};
79682 +} __do_const;
79683
79684 struct snd_soc_platform {
79685 const char *name;
79686 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
79687 index 4ea4f98..a63629b 100644
79688 --- a/include/target/target_core_base.h
79689 +++ b/include/target/target_core_base.h
79690 @@ -653,7 +653,7 @@ struct se_device {
79691 spinlock_t stats_lock;
79692 /* Active commands on this virtual SE device */
79693 atomic_t simple_cmds;
79694 - atomic_t dev_ordered_id;
79695 + atomic_unchecked_t dev_ordered_id;
79696 atomic_t dev_ordered_sync;
79697 atomic_t dev_qf_count;
79698 int export_count;
79699 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
79700 new file mode 100644
79701 index 0000000..fb634b7
79702 --- /dev/null
79703 +++ b/include/trace/events/fs.h
79704 @@ -0,0 +1,53 @@
79705 +#undef TRACE_SYSTEM
79706 +#define TRACE_SYSTEM fs
79707 +
79708 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
79709 +#define _TRACE_FS_H
79710 +
79711 +#include <linux/fs.h>
79712 +#include <linux/tracepoint.h>
79713 +
79714 +TRACE_EVENT(do_sys_open,
79715 +
79716 + TP_PROTO(const char *filename, int flags, int mode),
79717 +
79718 + TP_ARGS(filename, flags, mode),
79719 +
79720 + TP_STRUCT__entry(
79721 + __string( filename, filename )
79722 + __field( int, flags )
79723 + __field( int, mode )
79724 + ),
79725 +
79726 + TP_fast_assign(
79727 + __assign_str(filename, filename);
79728 + __entry->flags = flags;
79729 + __entry->mode = mode;
79730 + ),
79731 +
79732 + TP_printk("\"%s\" %x %o",
79733 + __get_str(filename), __entry->flags, __entry->mode)
79734 +);
79735 +
79736 +TRACE_EVENT(open_exec,
79737 +
79738 + TP_PROTO(const char *filename),
79739 +
79740 + TP_ARGS(filename),
79741 +
79742 + TP_STRUCT__entry(
79743 + __string( filename, filename )
79744 + ),
79745 +
79746 + TP_fast_assign(
79747 + __assign_str(filename, filename);
79748 + ),
79749 +
79750 + TP_printk("\"%s\"",
79751 + __get_str(filename))
79752 +);
79753 +
79754 +#endif /* _TRACE_FS_H */
79755 +
79756 +/* This part must be outside protection */
79757 +#include <trace/define_trace.h>
79758 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
79759 index 1c09820..7f5ec79 100644
79760 --- a/include/trace/events/irq.h
79761 +++ b/include/trace/events/irq.h
79762 @@ -36,7 +36,7 @@ struct softirq_action;
79763 */
79764 TRACE_EVENT(irq_handler_entry,
79765
79766 - TP_PROTO(int irq, struct irqaction *action),
79767 + TP_PROTO(int irq, const struct irqaction *action),
79768
79769 TP_ARGS(irq, action),
79770
79771 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
79772 */
79773 TRACE_EVENT(irq_handler_exit,
79774
79775 - TP_PROTO(int irq, struct irqaction *action, int ret),
79776 + TP_PROTO(int irq, const struct irqaction *action, int ret),
79777
79778 TP_ARGS(irq, action, ret),
79779
79780 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
79781 index 7caf44c..23c6f27 100644
79782 --- a/include/uapi/linux/a.out.h
79783 +++ b/include/uapi/linux/a.out.h
79784 @@ -39,6 +39,14 @@ enum machine_type {
79785 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
79786 };
79787
79788 +/* Constants for the N_FLAGS field */
79789 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79790 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
79791 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
79792 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
79793 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79794 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79795 +
79796 #if !defined (N_MAGIC)
79797 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
79798 #endif
79799 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
79800 index d876736..ccce5c0 100644
79801 --- a/include/uapi/linux/byteorder/little_endian.h
79802 +++ b/include/uapi/linux/byteorder/little_endian.h
79803 @@ -42,51 +42,51 @@
79804
79805 static inline __le64 __cpu_to_le64p(const __u64 *p)
79806 {
79807 - return (__force __le64)*p;
79808 + return (__force const __le64)*p;
79809 }
79810 -static inline __u64 __le64_to_cpup(const __le64 *p)
79811 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
79812 {
79813 - return (__force __u64)*p;
79814 + return (__force const __u64)*p;
79815 }
79816 static inline __le32 __cpu_to_le32p(const __u32 *p)
79817 {
79818 - return (__force __le32)*p;
79819 + return (__force const __le32)*p;
79820 }
79821 static inline __u32 __le32_to_cpup(const __le32 *p)
79822 {
79823 - return (__force __u32)*p;
79824 + return (__force const __u32)*p;
79825 }
79826 static inline __le16 __cpu_to_le16p(const __u16 *p)
79827 {
79828 - return (__force __le16)*p;
79829 + return (__force const __le16)*p;
79830 }
79831 static inline __u16 __le16_to_cpup(const __le16 *p)
79832 {
79833 - return (__force __u16)*p;
79834 + return (__force const __u16)*p;
79835 }
79836 static inline __be64 __cpu_to_be64p(const __u64 *p)
79837 {
79838 - return (__force __be64)__swab64p(p);
79839 + return (__force const __be64)__swab64p(p);
79840 }
79841 static inline __u64 __be64_to_cpup(const __be64 *p)
79842 {
79843 - return __swab64p((__u64 *)p);
79844 + return __swab64p((const __u64 *)p);
79845 }
79846 static inline __be32 __cpu_to_be32p(const __u32 *p)
79847 {
79848 - return (__force __be32)__swab32p(p);
79849 + return (__force const __be32)__swab32p(p);
79850 }
79851 -static inline __u32 __be32_to_cpup(const __be32 *p)
79852 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
79853 {
79854 - return __swab32p((__u32 *)p);
79855 + return __swab32p((const __u32 *)p);
79856 }
79857 static inline __be16 __cpu_to_be16p(const __u16 *p)
79858 {
79859 - return (__force __be16)__swab16p(p);
79860 + return (__force const __be16)__swab16p(p);
79861 }
79862 static inline __u16 __be16_to_cpup(const __be16 *p)
79863 {
79864 - return __swab16p((__u16 *)p);
79865 + return __swab16p((const __u16 *)p);
79866 }
79867 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
79868 #define __le64_to_cpus(x) do { (void)(x); } while (0)
79869 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
79870 index ef6103b..d4e65dd 100644
79871 --- a/include/uapi/linux/elf.h
79872 +++ b/include/uapi/linux/elf.h
79873 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
79874 #define PT_GNU_EH_FRAME 0x6474e550
79875
79876 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
79877 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
79878 +
79879 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
79880 +
79881 +/* Constants for the e_flags field */
79882 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79883 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
79884 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
79885 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
79886 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79887 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79888
79889 /*
79890 * Extended Numbering
79891 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
79892 #define DT_DEBUG 21
79893 #define DT_TEXTREL 22
79894 #define DT_JMPREL 23
79895 +#define DT_FLAGS 30
79896 + #define DF_TEXTREL 0x00000004
79897 #define DT_ENCODING 32
79898 #define OLD_DT_LOOS 0x60000000
79899 #define DT_LOOS 0x6000000d
79900 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
79901 #define PF_W 0x2
79902 #define PF_X 0x1
79903
79904 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
79905 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
79906 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
79907 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
79908 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
79909 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
79910 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
79911 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
79912 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
79913 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
79914 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
79915 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
79916 +
79917 typedef struct elf32_phdr{
79918 Elf32_Word p_type;
79919 Elf32_Off p_offset;
79920 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
79921 #define EI_OSABI 7
79922 #define EI_PAD 8
79923
79924 +#define EI_PAX 14
79925 +
79926 #define ELFMAG0 0x7f /* EI_MAG */
79927 #define ELFMAG1 'E'
79928 #define ELFMAG2 'L'
79929 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
79930 index aa169c4..6a2771d 100644
79931 --- a/include/uapi/linux/personality.h
79932 +++ b/include/uapi/linux/personality.h
79933 @@ -30,6 +30,7 @@ enum {
79934 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
79935 ADDR_NO_RANDOMIZE | \
79936 ADDR_COMPAT_LAYOUT | \
79937 + ADDR_LIMIT_3GB | \
79938 MMAP_PAGE_ZERO)
79939
79940 /*
79941 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
79942 index 7530e74..e714828 100644
79943 --- a/include/uapi/linux/screen_info.h
79944 +++ b/include/uapi/linux/screen_info.h
79945 @@ -43,7 +43,8 @@ struct screen_info {
79946 __u16 pages; /* 0x32 */
79947 __u16 vesa_attributes; /* 0x34 */
79948 __u32 capabilities; /* 0x36 */
79949 - __u8 _reserved[6]; /* 0x3a */
79950 + __u16 vesapm_size; /* 0x3a */
79951 + __u8 _reserved[4]; /* 0x3c */
79952 } __attribute__((packed));
79953
79954 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
79955 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
79956 index 0e011eb..82681b1 100644
79957 --- a/include/uapi/linux/swab.h
79958 +++ b/include/uapi/linux/swab.h
79959 @@ -43,7 +43,7 @@
79960 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
79961 */
79962
79963 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
79964 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
79965 {
79966 #ifdef __HAVE_BUILTIN_BSWAP16__
79967 return __builtin_bswap16(val);
79968 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
79969 #endif
79970 }
79971
79972 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
79973 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
79974 {
79975 #ifdef __HAVE_BUILTIN_BSWAP32__
79976 return __builtin_bswap32(val);
79977 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
79978 #endif
79979 }
79980
79981 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
79982 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
79983 {
79984 #ifdef __HAVE_BUILTIN_BSWAP64__
79985 return __builtin_bswap64(val);
79986 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
79987 index 6d67213..8dab561 100644
79988 --- a/include/uapi/linux/sysctl.h
79989 +++ b/include/uapi/linux/sysctl.h
79990 @@ -155,7 +155,11 @@ enum
79991 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
79992 };
79993
79994 -
79995 +#ifdef CONFIG_PAX_SOFTMODE
79996 +enum {
79997 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79998 +};
79999 +#endif
80000
80001 /* CTL_VM names: */
80002 enum
80003 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
80004 index e4629b9..6958086 100644
80005 --- a/include/uapi/linux/xattr.h
80006 +++ b/include/uapi/linux/xattr.h
80007 @@ -63,5 +63,9 @@
80008 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
80009 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
80010
80011 +/* User namespace */
80012 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
80013 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
80014 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
80015
80016 #endif /* _UAPI_LINUX_XATTR_H */
80017 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
80018 index f9466fa..f4e2b81 100644
80019 --- a/include/video/udlfb.h
80020 +++ b/include/video/udlfb.h
80021 @@ -53,10 +53,10 @@ struct dlfb_data {
80022 u32 pseudo_palette[256];
80023 int blank_mode; /*one of FB_BLANK_ */
80024 /* blit-only rendering path metrics, exposed through sysfs */
80025 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80026 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
80027 - atomic_t bytes_sent; /* to usb, after compression including overhead */
80028 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
80029 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80030 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
80031 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
80032 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
80033 };
80034
80035 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
80036 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
80037 index 1a91850..28573f8 100644
80038 --- a/include/video/uvesafb.h
80039 +++ b/include/video/uvesafb.h
80040 @@ -122,6 +122,7 @@ struct uvesafb_par {
80041 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
80042 u8 pmi_setpal; /* PMI for palette changes */
80043 u16 *pmi_base; /* protected mode interface location */
80044 + u8 *pmi_code; /* protected mode code location */
80045 void *pmi_start;
80046 void *pmi_pal;
80047 u8 *vbe_state_orig; /*
80048 diff --git a/init/Kconfig b/init/Kconfig
80049 index 2d9b831..ae4c8ac 100644
80050 --- a/init/Kconfig
80051 +++ b/init/Kconfig
80052 @@ -1029,6 +1029,7 @@ endif # CGROUPS
80053
80054 config CHECKPOINT_RESTORE
80055 bool "Checkpoint/restore support" if EXPERT
80056 + depends on !GRKERNSEC
80057 default n
80058 help
80059 Enables additional kernel features in a sake of checkpoint/restore.
80060 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
80061
80062 config COMPAT_BRK
80063 bool "Disable heap randomization"
80064 - default y
80065 + default n
80066 help
80067 Randomizing heap placement makes heap exploits harder, but it
80068 also breaks ancient binaries (including anything libc5 based).
80069 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
80070 config STOP_MACHINE
80071 bool
80072 default y
80073 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
80074 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
80075 help
80076 Need stop_machine() primitive.
80077
80078 diff --git a/init/Makefile b/init/Makefile
80079 index 7bc47ee..6da2dc7 100644
80080 --- a/init/Makefile
80081 +++ b/init/Makefile
80082 @@ -2,6 +2,9 @@
80083 # Makefile for the linux kernel.
80084 #
80085
80086 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
80087 +asflags-y := $(GCC_PLUGINS_AFLAGS)
80088 +
80089 obj-y := main.o version.o mounts.o
80090 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
80091 obj-y += noinitramfs.o
80092 diff --git a/init/do_mounts.c b/init/do_mounts.c
80093 index a2b49f2..03a0e17c 100644
80094 --- a/init/do_mounts.c
80095 +++ b/init/do_mounts.c
80096 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
80097 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
80098 {
80099 struct super_block *s;
80100 - int err = sys_mount(name, "/root", fs, flags, data);
80101 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
80102 if (err)
80103 return err;
80104
80105 - sys_chdir("/root");
80106 + sys_chdir((const char __force_user *)"/root");
80107 s = current->fs->pwd.dentry->d_sb;
80108 ROOT_DEV = s->s_dev;
80109 printk(KERN_INFO
80110 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
80111 va_start(args, fmt);
80112 vsprintf(buf, fmt, args);
80113 va_end(args);
80114 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
80115 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
80116 if (fd >= 0) {
80117 sys_ioctl(fd, FDEJECT, 0);
80118 sys_close(fd);
80119 }
80120 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
80121 - fd = sys_open("/dev/console", O_RDWR, 0);
80122 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
80123 if (fd >= 0) {
80124 sys_ioctl(fd, TCGETS, (long)&termios);
80125 termios.c_lflag &= ~ICANON;
80126 sys_ioctl(fd, TCSETSF, (long)&termios);
80127 - sys_read(fd, &c, 1);
80128 + sys_read(fd, (char __user *)&c, 1);
80129 termios.c_lflag |= ICANON;
80130 sys_ioctl(fd, TCSETSF, (long)&termios);
80131 sys_close(fd);
80132 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
80133 mount_root();
80134 out:
80135 devtmpfs_mount("dev");
80136 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80137 - sys_chroot(".");
80138 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80139 + sys_chroot((const char __force_user *)".");
80140 }
80141 diff --git a/init/do_mounts.h b/init/do_mounts.h
80142 index f5b978a..69dbfe8 100644
80143 --- a/init/do_mounts.h
80144 +++ b/init/do_mounts.h
80145 @@ -15,15 +15,15 @@ extern int root_mountflags;
80146
80147 static inline int create_dev(char *name, dev_t dev)
80148 {
80149 - sys_unlink(name);
80150 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
80151 + sys_unlink((char __force_user *)name);
80152 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
80153 }
80154
80155 #if BITS_PER_LONG == 32
80156 static inline u32 bstat(char *name)
80157 {
80158 struct stat64 stat;
80159 - if (sys_stat64(name, &stat) != 0)
80160 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
80161 return 0;
80162 if (!S_ISBLK(stat.st_mode))
80163 return 0;
80164 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
80165 static inline u32 bstat(char *name)
80166 {
80167 struct stat stat;
80168 - if (sys_newstat(name, &stat) != 0)
80169 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
80170 return 0;
80171 if (!S_ISBLK(stat.st_mode))
80172 return 0;
80173 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
80174 index 3e0878e..8a9d7a0 100644
80175 --- a/init/do_mounts_initrd.c
80176 +++ b/init/do_mounts_initrd.c
80177 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
80178 {
80179 sys_unshare(CLONE_FS | CLONE_FILES);
80180 /* stdin/stdout/stderr for /linuxrc */
80181 - sys_open("/dev/console", O_RDWR, 0);
80182 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
80183 sys_dup(0);
80184 sys_dup(0);
80185 /* move initrd over / and chdir/chroot in initrd root */
80186 - sys_chdir("/root");
80187 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80188 - sys_chroot(".");
80189 + sys_chdir((const char __force_user *)"/root");
80190 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80191 + sys_chroot((const char __force_user *)".");
80192 sys_setsid();
80193 return 0;
80194 }
80195 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
80196 create_dev("/dev/root.old", Root_RAM0);
80197 /* mount initrd on rootfs' /root */
80198 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
80199 - sys_mkdir("/old", 0700);
80200 - sys_chdir("/old");
80201 + sys_mkdir((const char __force_user *)"/old", 0700);
80202 + sys_chdir((const char __force_user *)"/old");
80203
80204 /* try loading default modules from initrd */
80205 load_default_modules();
80206 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
80207 current->flags &= ~PF_FREEZER_SKIP;
80208
80209 /* move initrd to rootfs' /old */
80210 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
80211 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
80212 /* switch root and cwd back to / of rootfs */
80213 - sys_chroot("..");
80214 + sys_chroot((const char __force_user *)"..");
80215
80216 if (new_decode_dev(real_root_dev) == Root_RAM0) {
80217 - sys_chdir("/old");
80218 + sys_chdir((const char __force_user *)"/old");
80219 return;
80220 }
80221
80222 - sys_chdir("/");
80223 + sys_chdir((const char __force_user *)"/");
80224 ROOT_DEV = new_decode_dev(real_root_dev);
80225 mount_root();
80226
80227 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
80228 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
80229 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
80230 if (!error)
80231 printk("okay\n");
80232 else {
80233 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
80234 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
80235 if (error == -ENOENT)
80236 printk("/initrd does not exist. Ignored.\n");
80237 else
80238 printk("failed\n");
80239 printk(KERN_NOTICE "Unmounting old root\n");
80240 - sys_umount("/old", MNT_DETACH);
80241 + sys_umount((char __force_user *)"/old", MNT_DETACH);
80242 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
80243 if (fd < 0) {
80244 error = fd;
80245 @@ -127,11 +127,11 @@ int __init initrd_load(void)
80246 * mounted in the normal path.
80247 */
80248 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
80249 - sys_unlink("/initrd.image");
80250 + sys_unlink((const char __force_user *)"/initrd.image");
80251 handle_initrd();
80252 return 1;
80253 }
80254 }
80255 - sys_unlink("/initrd.image");
80256 + sys_unlink((const char __force_user *)"/initrd.image");
80257 return 0;
80258 }
80259 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
80260 index 8cb6db5..d729f50 100644
80261 --- a/init/do_mounts_md.c
80262 +++ b/init/do_mounts_md.c
80263 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
80264 partitioned ? "_d" : "", minor,
80265 md_setup_args[ent].device_names);
80266
80267 - fd = sys_open(name, 0, 0);
80268 + fd = sys_open((char __force_user *)name, 0, 0);
80269 if (fd < 0) {
80270 printk(KERN_ERR "md: open failed - cannot start "
80271 "array %s\n", name);
80272 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
80273 * array without it
80274 */
80275 sys_close(fd);
80276 - fd = sys_open(name, 0, 0);
80277 + fd = sys_open((char __force_user *)name, 0, 0);
80278 sys_ioctl(fd, BLKRRPART, 0);
80279 }
80280 sys_close(fd);
80281 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
80282
80283 wait_for_device_probe();
80284
80285 - fd = sys_open("/dev/md0", 0, 0);
80286 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
80287 if (fd >= 0) {
80288 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
80289 sys_close(fd);
80290 diff --git a/init/init_task.c b/init/init_task.c
80291 index ba0a7f36..2bcf1d5 100644
80292 --- a/init/init_task.c
80293 +++ b/init/init_task.c
80294 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
80295 * Initial thread structure. Alignment of this is handled by a special
80296 * linker map entry.
80297 */
80298 +#ifdef CONFIG_X86
80299 +union thread_union init_thread_union __init_task_data;
80300 +#else
80301 union thread_union init_thread_union __init_task_data =
80302 { INIT_THREAD_INFO(init_task) };
80303 +#endif
80304 diff --git a/init/initramfs.c b/init/initramfs.c
80305 index a67ef9d..2d17ed9 100644
80306 --- a/init/initramfs.c
80307 +++ b/init/initramfs.c
80308 @@ -84,7 +84,7 @@ static void __init free_hash(void)
80309 }
80310 }
80311
80312 -static long __init do_utime(char *filename, time_t mtime)
80313 +static long __init do_utime(char __force_user *filename, time_t mtime)
80314 {
80315 struct timespec t[2];
80316
80317 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
80318 struct dir_entry *de, *tmp;
80319 list_for_each_entry_safe(de, tmp, &dir_list, list) {
80320 list_del(&de->list);
80321 - do_utime(de->name, de->mtime);
80322 + do_utime((char __force_user *)de->name, de->mtime);
80323 kfree(de->name);
80324 kfree(de);
80325 }
80326 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
80327 if (nlink >= 2) {
80328 char *old = find_link(major, minor, ino, mode, collected);
80329 if (old)
80330 - return (sys_link(old, collected) < 0) ? -1 : 1;
80331 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
80332 }
80333 return 0;
80334 }
80335 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
80336 {
80337 struct stat st;
80338
80339 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
80340 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
80341 if (S_ISDIR(st.st_mode))
80342 - sys_rmdir(path);
80343 + sys_rmdir((char __force_user *)path);
80344 else
80345 - sys_unlink(path);
80346 + sys_unlink((char __force_user *)path);
80347 }
80348 }
80349
80350 @@ -315,7 +315,7 @@ static int __init do_name(void)
80351 int openflags = O_WRONLY|O_CREAT;
80352 if (ml != 1)
80353 openflags |= O_TRUNC;
80354 - wfd = sys_open(collected, openflags, mode);
80355 + wfd = sys_open((char __force_user *)collected, openflags, mode);
80356
80357 if (wfd >= 0) {
80358 sys_fchown(wfd, uid, gid);
80359 @@ -327,17 +327,17 @@ static int __init do_name(void)
80360 }
80361 }
80362 } else if (S_ISDIR(mode)) {
80363 - sys_mkdir(collected, mode);
80364 - sys_chown(collected, uid, gid);
80365 - sys_chmod(collected, mode);
80366 + sys_mkdir((char __force_user *)collected, mode);
80367 + sys_chown((char __force_user *)collected, uid, gid);
80368 + sys_chmod((char __force_user *)collected, mode);
80369 dir_add(collected, mtime);
80370 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
80371 S_ISFIFO(mode) || S_ISSOCK(mode)) {
80372 if (maybe_link() == 0) {
80373 - sys_mknod(collected, mode, rdev);
80374 - sys_chown(collected, uid, gid);
80375 - sys_chmod(collected, mode);
80376 - do_utime(collected, mtime);
80377 + sys_mknod((char __force_user *)collected, mode, rdev);
80378 + sys_chown((char __force_user *)collected, uid, gid);
80379 + sys_chmod((char __force_user *)collected, mode);
80380 + do_utime((char __force_user *)collected, mtime);
80381 }
80382 }
80383 return 0;
80384 @@ -346,15 +346,15 @@ static int __init do_name(void)
80385 static int __init do_copy(void)
80386 {
80387 if (count >= body_len) {
80388 - sys_write(wfd, victim, body_len);
80389 + sys_write(wfd, (char __force_user *)victim, body_len);
80390 sys_close(wfd);
80391 - do_utime(vcollected, mtime);
80392 + do_utime((char __force_user *)vcollected, mtime);
80393 kfree(vcollected);
80394 eat(body_len);
80395 state = SkipIt;
80396 return 0;
80397 } else {
80398 - sys_write(wfd, victim, count);
80399 + sys_write(wfd, (char __force_user *)victim, count);
80400 body_len -= count;
80401 eat(count);
80402 return 1;
80403 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80404 {
80405 collected[N_ALIGN(name_len) + body_len] = '\0';
80406 clean_path(collected, 0);
80407 - sys_symlink(collected + N_ALIGN(name_len), collected);
80408 - sys_lchown(collected, uid, gid);
80409 - do_utime(collected, mtime);
80410 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80411 + sys_lchown((char __force_user *)collected, uid, gid);
80412 + do_utime((char __force_user *)collected, mtime);
80413 state = SkipIt;
80414 next_state = Reset;
80415 return 0;
80416 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80417 {
80418 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80419 if (err)
80420 - panic(err); /* Failed to decompress INTERNAL initramfs */
80421 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80422 if (initrd_start) {
80423 #ifdef CONFIG_BLK_DEV_RAM
80424 int fd;
80425 diff --git a/init/main.c b/init/main.c
80426 index 9484f4b..0eac7c3 100644
80427 --- a/init/main.c
80428 +++ b/init/main.c
80429 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
80430 extern void tc_init(void);
80431 #endif
80432
80433 +extern void grsecurity_init(void);
80434 +
80435 /*
80436 * Debug helper: via this flag we know that we are in 'early bootup code'
80437 * where only the boot processor is running with IRQ disabled. This means
80438 @@ -153,6 +155,74 @@ static int __init set_reset_devices(char *str)
80439
80440 __setup("reset_devices", set_reset_devices);
80441
80442 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80443 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80444 +static int __init setup_grsec_proc_gid(char *str)
80445 +{
80446 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80447 + return 1;
80448 +}
80449 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80450 +#endif
80451 +
80452 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80453 +unsigned long pax_user_shadow_base __read_only;
80454 +EXPORT_SYMBOL(pax_user_shadow_base);
80455 +extern char pax_enter_kernel_user[];
80456 +extern char pax_exit_kernel_user[];
80457 +#endif
80458 +
80459 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80460 +static int __init setup_pax_nouderef(char *str)
80461 +{
80462 +#ifdef CONFIG_X86_32
80463 + unsigned int cpu;
80464 + struct desc_struct *gdt;
80465 +
80466 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80467 + gdt = get_cpu_gdt_table(cpu);
80468 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80469 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80470 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80471 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80472 + }
80473 + loadsegment(ds, __KERNEL_DS);
80474 + loadsegment(es, __KERNEL_DS);
80475 + loadsegment(ss, __KERNEL_DS);
80476 +#else
80477 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80478 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80479 + clone_pgd_mask = ~(pgdval_t)0UL;
80480 + pax_user_shadow_base = 0UL;
80481 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80482 +#endif
80483 +
80484 + return 0;
80485 +}
80486 +early_param("pax_nouderef", setup_pax_nouderef);
80487 +
80488 +#ifdef CONFIG_X86_64
80489 +static int __init setup_pax_weakuderef(char *str)
80490 +{
80491 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80492 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80493 + return 1;
80494 +}
80495 +__setup("pax_weakuderef", setup_pax_weakuderef);
80496 +#endif
80497 +#endif
80498 +
80499 +#ifdef CONFIG_PAX_SOFTMODE
80500 +int pax_softmode;
80501 +
80502 +static int __init setup_pax_softmode(char *str)
80503 +{
80504 + get_option(&str, &pax_softmode);
80505 + return 1;
80506 +}
80507 +__setup("pax_softmode=", setup_pax_softmode);
80508 +#endif
80509 +
80510 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80511 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80512 static const char *panic_later, *panic_param;
80513 @@ -655,8 +725,6 @@ static void __init do_ctors(void)
80514 bool initcall_debug;
80515 core_param(initcall_debug, initcall_debug, bool, 0644);
80516
80517 -static char msgbuf[64];
80518 -
80519 static int __init_or_module do_one_initcall_debug(initcall_t fn)
80520 {
80521 ktime_t calltime, delta, rettime;
80522 @@ -679,23 +747,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
80523 {
80524 int count = preempt_count();
80525 int ret;
80526 + const char *msg1 = "", *msg2 = "";
80527
80528 if (initcall_debug)
80529 ret = do_one_initcall_debug(fn);
80530 else
80531 ret = fn();
80532
80533 - msgbuf[0] = 0;
80534 -
80535 if (preempt_count() != count) {
80536 - sprintf(msgbuf, "preemption imbalance ");
80537 + msg1 = " preemption imbalance";
80538 preempt_count() = count;
80539 }
80540 if (irqs_disabled()) {
80541 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80542 + msg2 = " disabled interrupts";
80543 local_irq_enable();
80544 }
80545 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80546 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80547
80548 return ret;
80549 }
80550 @@ -748,8 +815,14 @@ static void __init do_initcall_level(int level)
80551 level, level,
80552 &repair_env_string);
80553
80554 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
80555 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
80556 do_one_initcall(*fn);
80557 +
80558 +#ifdef LATENT_ENTROPY_PLUGIN
80559 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
80560 +#endif
80561 +
80562 + }
80563 }
80564
80565 static void __init do_initcalls(void)
80566 @@ -783,8 +856,14 @@ static void __init do_pre_smp_initcalls(void)
80567 {
80568 initcall_t *fn;
80569
80570 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
80571 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
80572 do_one_initcall(*fn);
80573 +
80574 +#ifdef LATENT_ENTROPY_PLUGIN
80575 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
80576 +#endif
80577 +
80578 + }
80579 }
80580
80581 /*
80582 @@ -802,8 +881,8 @@ static int run_init_process(const char *init_filename)
80583 {
80584 argv_init[0] = init_filename;
80585 return do_execve(init_filename,
80586 - (const char __user *const __user *)argv_init,
80587 - (const char __user *const __user *)envp_init);
80588 + (const char __user *const __force_user *)argv_init,
80589 + (const char __user *const __force_user *)envp_init);
80590 }
80591
80592 static noinline void __init kernel_init_freeable(void);
80593 @@ -880,7 +959,7 @@ static noinline void __init kernel_init_freeable(void)
80594 do_basic_setup();
80595
80596 /* Open the /dev/console on the rootfs, this should never fail */
80597 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80598 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80599 pr_err("Warning: unable to open an initial console.\n");
80600
80601 (void) sys_dup(0);
80602 @@ -893,11 +972,13 @@ static noinline void __init kernel_init_freeable(void)
80603 if (!ramdisk_execute_command)
80604 ramdisk_execute_command = "/init";
80605
80606 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80607 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80608 ramdisk_execute_command = NULL;
80609 prepare_namespace();
80610 }
80611
80612 + grsecurity_init();
80613 +
80614 /*
80615 * Ok, we have completed the initial bootup, and
80616 * we're essentially up and running. Get rid of the
80617 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80618 index 130dfec..cc88451 100644
80619 --- a/ipc/ipc_sysctl.c
80620 +++ b/ipc/ipc_sysctl.c
80621 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80622 static int proc_ipc_dointvec(ctl_table *table, int write,
80623 void __user *buffer, size_t *lenp, loff_t *ppos)
80624 {
80625 - struct ctl_table ipc_table;
80626 + ctl_table_no_const ipc_table;
80627
80628 memcpy(&ipc_table, table, sizeof(ipc_table));
80629 ipc_table.data = get_ipc(table);
80630 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80631 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80632 void __user *buffer, size_t *lenp, loff_t *ppos)
80633 {
80634 - struct ctl_table ipc_table;
80635 + ctl_table_no_const ipc_table;
80636
80637 memcpy(&ipc_table, table, sizeof(ipc_table));
80638 ipc_table.data = get_ipc(table);
80639 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80640 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
80641 void __user *buffer, size_t *lenp, loff_t *ppos)
80642 {
80643 - struct ctl_table ipc_table;
80644 + ctl_table_no_const ipc_table;
80645 size_t lenp_bef = *lenp;
80646 int rc;
80647
80648 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
80649 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
80650 void __user *buffer, size_t *lenp, loff_t *ppos)
80651 {
80652 - struct ctl_table ipc_table;
80653 + ctl_table_no_const ipc_table;
80654 memcpy(&ipc_table, table, sizeof(ipc_table));
80655 ipc_table.data = get_ipc(table);
80656
80657 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
80658 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
80659 void __user *buffer, size_t *lenp, loff_t *ppos)
80660 {
80661 - struct ctl_table ipc_table;
80662 + ctl_table_no_const ipc_table;
80663 size_t lenp_bef = *lenp;
80664 int oldval;
80665 int rc;
80666 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
80667 index 383d638..943fdbb 100644
80668 --- a/ipc/mq_sysctl.c
80669 +++ b/ipc/mq_sysctl.c
80670 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
80671 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
80672 void __user *buffer, size_t *lenp, loff_t *ppos)
80673 {
80674 - struct ctl_table mq_table;
80675 + ctl_table_no_const mq_table;
80676 memcpy(&mq_table, table, sizeof(mq_table));
80677 mq_table.data = get_mq(table);
80678
80679 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
80680 index e4e47f6..a85e0ad 100644
80681 --- a/ipc/mqueue.c
80682 +++ b/ipc/mqueue.c
80683 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
80684 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
80685 info->attr.mq_msgsize);
80686
80687 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
80688 spin_lock(&mq_lock);
80689 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
80690 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
80691 diff --git a/ipc/msg.c b/ipc/msg.c
80692 index d0c6d96..69a893c 100644
80693 --- a/ipc/msg.c
80694 +++ b/ipc/msg.c
80695 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
80696 return security_msg_queue_associate(msq, msgflg);
80697 }
80698
80699 +static struct ipc_ops msg_ops = {
80700 + .getnew = newque,
80701 + .associate = msg_security,
80702 + .more_checks = NULL
80703 +};
80704 +
80705 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
80706 {
80707 struct ipc_namespace *ns;
80708 - struct ipc_ops msg_ops;
80709 struct ipc_params msg_params;
80710
80711 ns = current->nsproxy->ipc_ns;
80712
80713 - msg_ops.getnew = newque;
80714 - msg_ops.associate = msg_security;
80715 - msg_ops.more_checks = NULL;
80716 -
80717 msg_params.key = key;
80718 msg_params.flg = msgflg;
80719
80720 diff --git a/ipc/sem.c b/ipc/sem.c
80721 index 70480a3..f4e8262 100644
80722 --- a/ipc/sem.c
80723 +++ b/ipc/sem.c
80724 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
80725 return 0;
80726 }
80727
80728 +static struct ipc_ops sem_ops = {
80729 + .getnew = newary,
80730 + .associate = sem_security,
80731 + .more_checks = sem_more_checks
80732 +};
80733 +
80734 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80735 {
80736 struct ipc_namespace *ns;
80737 - struct ipc_ops sem_ops;
80738 struct ipc_params sem_params;
80739
80740 ns = current->nsproxy->ipc_ns;
80741 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80742 if (nsems < 0 || nsems > ns->sc_semmsl)
80743 return -EINVAL;
80744
80745 - sem_ops.getnew = newary;
80746 - sem_ops.associate = sem_security;
80747 - sem_ops.more_checks = sem_more_checks;
80748 -
80749 sem_params.key = key;
80750 sem_params.flg = semflg;
80751 sem_params.u.nsems = nsems;
80752 diff --git a/ipc/shm.c b/ipc/shm.c
80753 index 7e199fa..180a1ca 100644
80754 --- a/ipc/shm.c
80755 +++ b/ipc/shm.c
80756 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
80757 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
80758 #endif
80759
80760 +#ifdef CONFIG_GRKERNSEC
80761 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80762 + const time_t shm_createtime, const kuid_t cuid,
80763 + const int shmid);
80764 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80765 + const time_t shm_createtime);
80766 +#endif
80767 +
80768 void shm_init_ns(struct ipc_namespace *ns)
80769 {
80770 ns->shm_ctlmax = SHMMAX;
80771 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
80772 shp->shm_lprid = 0;
80773 shp->shm_atim = shp->shm_dtim = 0;
80774 shp->shm_ctim = get_seconds();
80775 +#ifdef CONFIG_GRKERNSEC
80776 + {
80777 + struct timespec timeval;
80778 + do_posix_clock_monotonic_gettime(&timeval);
80779 +
80780 + shp->shm_createtime = timeval.tv_sec;
80781 + }
80782 +#endif
80783 shp->shm_segsz = size;
80784 shp->shm_nattch = 0;
80785 shp->shm_file = file;
80786 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
80787 return 0;
80788 }
80789
80790 +static struct ipc_ops shm_ops = {
80791 + .getnew = newseg,
80792 + .associate = shm_security,
80793 + .more_checks = shm_more_checks
80794 +};
80795 +
80796 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
80797 {
80798 struct ipc_namespace *ns;
80799 - struct ipc_ops shm_ops;
80800 struct ipc_params shm_params;
80801
80802 ns = current->nsproxy->ipc_ns;
80803
80804 - shm_ops.getnew = newseg;
80805 - shm_ops.associate = shm_security;
80806 - shm_ops.more_checks = shm_more_checks;
80807 -
80808 shm_params.key = key;
80809 shm_params.flg = shmflg;
80810 shm_params.u.size = size;
80811 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80812 f_mode = FMODE_READ | FMODE_WRITE;
80813 }
80814 if (shmflg & SHM_EXEC) {
80815 +
80816 +#ifdef CONFIG_PAX_MPROTECT
80817 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
80818 + goto out;
80819 +#endif
80820 +
80821 prot |= PROT_EXEC;
80822 acc_mode |= S_IXUGO;
80823 }
80824 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80825 if (err)
80826 goto out_unlock;
80827
80828 +#ifdef CONFIG_GRKERNSEC
80829 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
80830 + shp->shm_perm.cuid, shmid) ||
80831 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
80832 + err = -EACCES;
80833 + goto out_unlock;
80834 + }
80835 +#endif
80836 +
80837 path = shp->shm_file->f_path;
80838 path_get(&path);
80839 shp->shm_nattch++;
80840 +#ifdef CONFIG_GRKERNSEC
80841 + shp->shm_lapid = current->pid;
80842 +#endif
80843 size = i_size_read(path.dentry->d_inode);
80844 shm_unlock(shp);
80845
80846 diff --git a/kernel/acct.c b/kernel/acct.c
80847 index 8d6e145..33e0b1e 100644
80848 --- a/kernel/acct.c
80849 +++ b/kernel/acct.c
80850 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
80851 */
80852 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
80853 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
80854 - file->f_op->write(file, (char *)&ac,
80855 + file->f_op->write(file, (char __force_user *)&ac,
80856 sizeof(acct_t), &file->f_pos);
80857 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
80858 set_fs(fs);
80859 diff --git a/kernel/audit.c b/kernel/audit.c
80860 index 91e53d0..d9e3ec4 100644
80861 --- a/kernel/audit.c
80862 +++ b/kernel/audit.c
80863 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
80864 3) suppressed due to audit_rate_limit
80865 4) suppressed due to audit_backlog_limit
80866 */
80867 -static atomic_t audit_lost = ATOMIC_INIT(0);
80868 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
80869
80870 /* The netlink socket. */
80871 static struct sock *audit_sock;
80872 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
80873 unsigned long now;
80874 int print;
80875
80876 - atomic_inc(&audit_lost);
80877 + atomic_inc_unchecked(&audit_lost);
80878
80879 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
80880
80881 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
80882 printk(KERN_WARNING
80883 "audit: audit_lost=%d audit_rate_limit=%d "
80884 "audit_backlog_limit=%d\n",
80885 - atomic_read(&audit_lost),
80886 + atomic_read_unchecked(&audit_lost),
80887 audit_rate_limit,
80888 audit_backlog_limit);
80889 audit_panic(message);
80890 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80891 status_set.pid = audit_pid;
80892 status_set.rate_limit = audit_rate_limit;
80893 status_set.backlog_limit = audit_backlog_limit;
80894 - status_set.lost = atomic_read(&audit_lost);
80895 + status_set.lost = atomic_read_unchecked(&audit_lost);
80896 status_set.backlog = skb_queue_len(&audit_skb_queue);
80897 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
80898 &status_set, sizeof(status_set));
80899 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
80900 index 6bd4a90..0ee9eff 100644
80901 --- a/kernel/auditfilter.c
80902 +++ b/kernel/auditfilter.c
80903 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
80904 f->lsm_rule = NULL;
80905
80906 /* Support legacy tests for a valid loginuid */
80907 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
80908 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
80909 f->type = AUDIT_LOGINUID_SET;
80910 f->val = 0;
80911 }
80912 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
80913 index 3c8a601..3a416f6 100644
80914 --- a/kernel/auditsc.c
80915 +++ b/kernel/auditsc.c
80916 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
80917 }
80918
80919 /* global counter which is incremented every time something logs in */
80920 -static atomic_t session_id = ATOMIC_INIT(0);
80921 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
80922
80923 /**
80924 * audit_set_loginuid - set current task's audit_context loginuid
80925 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
80926 return -EPERM;
80927 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
80928
80929 - sessionid = atomic_inc_return(&session_id);
80930 + sessionid = atomic_inc_return_unchecked(&session_id);
80931 if (context && context->in_syscall) {
80932 struct audit_buffer *ab;
80933
80934 diff --git a/kernel/capability.c b/kernel/capability.c
80935 index f6c2ce5..982c0f9 100644
80936 --- a/kernel/capability.c
80937 +++ b/kernel/capability.c
80938 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
80939 * before modification is attempted and the application
80940 * fails.
80941 */
80942 + if (tocopy > ARRAY_SIZE(kdata))
80943 + return -EFAULT;
80944 +
80945 if (copy_to_user(dataptr, kdata, tocopy
80946 * sizeof(struct __user_cap_data_struct))) {
80947 return -EFAULT;
80948 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
80949 int ret;
80950
80951 rcu_read_lock();
80952 - ret = security_capable(__task_cred(t), ns, cap);
80953 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
80954 + gr_task_is_capable(t, __task_cred(t), cap);
80955 rcu_read_unlock();
80956
80957 - return (ret == 0);
80958 + return ret;
80959 }
80960
80961 /**
80962 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
80963 int ret;
80964
80965 rcu_read_lock();
80966 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
80967 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
80968 rcu_read_unlock();
80969
80970 - return (ret == 0);
80971 + return ret;
80972 }
80973
80974 /**
80975 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80976 BUG();
80977 }
80978
80979 - if (security_capable(current_cred(), ns, cap) == 0) {
80980 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80981 current->flags |= PF_SUPERPRIV;
80982 return true;
80983 }
80984 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80985 }
80986 EXPORT_SYMBOL(ns_capable);
80987
80988 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80989 +{
80990 + if (unlikely(!cap_valid(cap))) {
80991 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80992 + BUG();
80993 + }
80994 +
80995 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80996 + current->flags |= PF_SUPERPRIV;
80997 + return true;
80998 + }
80999 + return false;
81000 +}
81001 +EXPORT_SYMBOL(ns_capable_nolog);
81002 +
81003 /**
81004 * file_ns_capable - Determine if the file's opener had a capability in effect
81005 * @file: The file we want to check
81006 @@ -432,6 +451,12 @@ bool capable(int cap)
81007 }
81008 EXPORT_SYMBOL(capable);
81009
81010 +bool capable_nolog(int cap)
81011 +{
81012 + return ns_capable_nolog(&init_user_ns, cap);
81013 +}
81014 +EXPORT_SYMBOL(capable_nolog);
81015 +
81016 /**
81017 * nsown_capable - Check superior capability to one's own user_ns
81018 * @cap: The capability in question
81019 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
81020
81021 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81022 }
81023 +
81024 +bool inode_capable_nolog(const struct inode *inode, int cap)
81025 +{
81026 + struct user_namespace *ns = current_user_ns();
81027 +
81028 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81029 +}
81030 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
81031 index 2e9b387..61817b1 100644
81032 --- a/kernel/cgroup.c
81033 +++ b/kernel/cgroup.c
81034 @@ -5398,7 +5398,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
81035 struct css_set *cg = link->cg;
81036 struct task_struct *task;
81037 int count = 0;
81038 - seq_printf(seq, "css_set %p\n", cg);
81039 + seq_printf(seq, "css_set %pK\n", cg);
81040 list_for_each_entry(task, &cg->tasks, cg_list) {
81041 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
81042 seq_puts(seq, " ...\n");
81043 diff --git a/kernel/compat.c b/kernel/compat.c
81044 index 0a09e48..f44f3f0 100644
81045 --- a/kernel/compat.c
81046 +++ b/kernel/compat.c
81047 @@ -13,6 +13,7 @@
81048
81049 #include <linux/linkage.h>
81050 #include <linux/compat.h>
81051 +#include <linux/module.h>
81052 #include <linux/errno.h>
81053 #include <linux/time.h>
81054 #include <linux/signal.h>
81055 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
81056 mm_segment_t oldfs;
81057 long ret;
81058
81059 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
81060 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
81061 oldfs = get_fs();
81062 set_fs(KERNEL_DS);
81063 ret = hrtimer_nanosleep_restart(restart);
81064 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
81065 oldfs = get_fs();
81066 set_fs(KERNEL_DS);
81067 ret = hrtimer_nanosleep(&tu,
81068 - rmtp ? (struct timespec __user *)&rmt : NULL,
81069 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
81070 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
81071 set_fs(oldfs);
81072
81073 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
81074 mm_segment_t old_fs = get_fs();
81075
81076 set_fs(KERNEL_DS);
81077 - ret = sys_sigpending((old_sigset_t __user *) &s);
81078 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
81079 set_fs(old_fs);
81080 if (ret == 0)
81081 ret = put_user(s, set);
81082 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
81083 mm_segment_t old_fs = get_fs();
81084
81085 set_fs(KERNEL_DS);
81086 - ret = sys_old_getrlimit(resource, &r);
81087 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
81088 set_fs(old_fs);
81089
81090 if (!ret) {
81091 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
81092 set_fs (KERNEL_DS);
81093 ret = sys_wait4(pid,
81094 (stat_addr ?
81095 - (unsigned int __user *) &status : NULL),
81096 - options, (struct rusage __user *) &r);
81097 + (unsigned int __force_user *) &status : NULL),
81098 + options, (struct rusage __force_user *) &r);
81099 set_fs (old_fs);
81100
81101 if (ret > 0) {
81102 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
81103 memset(&info, 0, sizeof(info));
81104
81105 set_fs(KERNEL_DS);
81106 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
81107 - uru ? (struct rusage __user *)&ru : NULL);
81108 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
81109 + uru ? (struct rusage __force_user *)&ru : NULL);
81110 set_fs(old_fs);
81111
81112 if ((ret < 0) || (info.si_signo == 0))
81113 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
81114 oldfs = get_fs();
81115 set_fs(KERNEL_DS);
81116 err = sys_timer_settime(timer_id, flags,
81117 - (struct itimerspec __user *) &newts,
81118 - (struct itimerspec __user *) &oldts);
81119 + (struct itimerspec __force_user *) &newts,
81120 + (struct itimerspec __force_user *) &oldts);
81121 set_fs(oldfs);
81122 if (!err && old && put_compat_itimerspec(old, &oldts))
81123 return -EFAULT;
81124 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
81125 oldfs = get_fs();
81126 set_fs(KERNEL_DS);
81127 err = sys_timer_gettime(timer_id,
81128 - (struct itimerspec __user *) &ts);
81129 + (struct itimerspec __force_user *) &ts);
81130 set_fs(oldfs);
81131 if (!err && put_compat_itimerspec(setting, &ts))
81132 return -EFAULT;
81133 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
81134 oldfs = get_fs();
81135 set_fs(KERNEL_DS);
81136 err = sys_clock_settime(which_clock,
81137 - (struct timespec __user *) &ts);
81138 + (struct timespec __force_user *) &ts);
81139 set_fs(oldfs);
81140 return err;
81141 }
81142 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
81143 oldfs = get_fs();
81144 set_fs(KERNEL_DS);
81145 err = sys_clock_gettime(which_clock,
81146 - (struct timespec __user *) &ts);
81147 + (struct timespec __force_user *) &ts);
81148 set_fs(oldfs);
81149 if (!err && put_compat_timespec(&ts, tp))
81150 return -EFAULT;
81151 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
81152
81153 oldfs = get_fs();
81154 set_fs(KERNEL_DS);
81155 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
81156 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
81157 set_fs(oldfs);
81158
81159 err = compat_put_timex(utp, &txc);
81160 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
81161 oldfs = get_fs();
81162 set_fs(KERNEL_DS);
81163 err = sys_clock_getres(which_clock,
81164 - (struct timespec __user *) &ts);
81165 + (struct timespec __force_user *) &ts);
81166 set_fs(oldfs);
81167 if (!err && tp && put_compat_timespec(&ts, tp))
81168 return -EFAULT;
81169 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
81170 long err;
81171 mm_segment_t oldfs;
81172 struct timespec tu;
81173 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
81174 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
81175
81176 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
81177 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
81178 oldfs = get_fs();
81179 set_fs(KERNEL_DS);
81180 err = clock_nanosleep_restart(restart);
81181 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
81182 oldfs = get_fs();
81183 set_fs(KERNEL_DS);
81184 err = sys_clock_nanosleep(which_clock, flags,
81185 - (struct timespec __user *) &in,
81186 - (struct timespec __user *) &out);
81187 + (struct timespec __force_user *) &in,
81188 + (struct timespec __force_user *) &out);
81189 set_fs(oldfs);
81190
81191 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
81192 diff --git a/kernel/configs.c b/kernel/configs.c
81193 index c18b1f1..b9a0132 100644
81194 --- a/kernel/configs.c
81195 +++ b/kernel/configs.c
81196 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
81197 struct proc_dir_entry *entry;
81198
81199 /* create the current config file */
81200 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81201 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
81202 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
81203 + &ikconfig_file_ops);
81204 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81205 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
81206 + &ikconfig_file_ops);
81207 +#endif
81208 +#else
81209 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
81210 &ikconfig_file_ops);
81211 +#endif
81212 +
81213 if (!entry)
81214 return -ENOMEM;
81215
81216 diff --git a/kernel/cred.c b/kernel/cred.c
81217 index e0573a4..3874e41 100644
81218 --- a/kernel/cred.c
81219 +++ b/kernel/cred.c
81220 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
81221 validate_creds(cred);
81222 alter_cred_subscribers(cred, -1);
81223 put_cred(cred);
81224 +
81225 +#ifdef CONFIG_GRKERNSEC_SETXID
81226 + cred = (struct cred *) tsk->delayed_cred;
81227 + if (cred != NULL) {
81228 + tsk->delayed_cred = NULL;
81229 + validate_creds(cred);
81230 + alter_cred_subscribers(cred, -1);
81231 + put_cred(cred);
81232 + }
81233 +#endif
81234 }
81235
81236 /**
81237 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
81238 * Always returns 0 thus allowing this function to be tail-called at the end
81239 * of, say, sys_setgid().
81240 */
81241 -int commit_creds(struct cred *new)
81242 +static int __commit_creds(struct cred *new)
81243 {
81244 struct task_struct *task = current;
81245 const struct cred *old = task->real_cred;
81246 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
81247
81248 get_cred(new); /* we will require a ref for the subj creds too */
81249
81250 + gr_set_role_label(task, new->uid, new->gid);
81251 +
81252 /* dumpability changes */
81253 if (!uid_eq(old->euid, new->euid) ||
81254 !gid_eq(old->egid, new->egid) ||
81255 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
81256 put_cred(old);
81257 return 0;
81258 }
81259 +#ifdef CONFIG_GRKERNSEC_SETXID
81260 +extern int set_user(struct cred *new);
81261 +
81262 +void gr_delayed_cred_worker(void)
81263 +{
81264 + const struct cred *new = current->delayed_cred;
81265 + struct cred *ncred;
81266 +
81267 + current->delayed_cred = NULL;
81268 +
81269 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
81270 + // from doing get_cred on it when queueing this
81271 + put_cred(new);
81272 + return;
81273 + } else if (new == NULL)
81274 + return;
81275 +
81276 + ncred = prepare_creds();
81277 + if (!ncred)
81278 + goto die;
81279 + // uids
81280 + ncred->uid = new->uid;
81281 + ncred->euid = new->euid;
81282 + ncred->suid = new->suid;
81283 + ncred->fsuid = new->fsuid;
81284 + // gids
81285 + ncred->gid = new->gid;
81286 + ncred->egid = new->egid;
81287 + ncred->sgid = new->sgid;
81288 + ncred->fsgid = new->fsgid;
81289 + // groups
81290 + if (set_groups(ncred, new->group_info) < 0) {
81291 + abort_creds(ncred);
81292 + goto die;
81293 + }
81294 + // caps
81295 + ncred->securebits = new->securebits;
81296 + ncred->cap_inheritable = new->cap_inheritable;
81297 + ncred->cap_permitted = new->cap_permitted;
81298 + ncred->cap_effective = new->cap_effective;
81299 + ncred->cap_bset = new->cap_bset;
81300 +
81301 + if (set_user(ncred)) {
81302 + abort_creds(ncred);
81303 + goto die;
81304 + }
81305 +
81306 + // from doing get_cred on it when queueing this
81307 + put_cred(new);
81308 +
81309 + __commit_creds(ncred);
81310 + return;
81311 +die:
81312 + // from doing get_cred on it when queueing this
81313 + put_cred(new);
81314 + do_group_exit(SIGKILL);
81315 +}
81316 +#endif
81317 +
81318 +int commit_creds(struct cred *new)
81319 +{
81320 +#ifdef CONFIG_GRKERNSEC_SETXID
81321 + int ret;
81322 + int schedule_it = 0;
81323 + struct task_struct *t;
81324 +
81325 + /* we won't get called with tasklist_lock held for writing
81326 + and interrupts disabled as the cred struct in that case is
81327 + init_cred
81328 + */
81329 + if (grsec_enable_setxid && !current_is_single_threaded() &&
81330 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
81331 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
81332 + schedule_it = 1;
81333 + }
81334 + ret = __commit_creds(new);
81335 + if (schedule_it) {
81336 + rcu_read_lock();
81337 + read_lock(&tasklist_lock);
81338 + for (t = next_thread(current); t != current;
81339 + t = next_thread(t)) {
81340 + if (t->delayed_cred == NULL) {
81341 + t->delayed_cred = get_cred(new);
81342 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
81343 + set_tsk_need_resched(t);
81344 + }
81345 + }
81346 + read_unlock(&tasklist_lock);
81347 + rcu_read_unlock();
81348 + }
81349 + return ret;
81350 +#else
81351 + return __commit_creds(new);
81352 +#endif
81353 +}
81354 +
81355 EXPORT_SYMBOL(commit_creds);
81356
81357 /**
81358 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
81359 index 0506d44..2c20034 100644
81360 --- a/kernel/debug/debug_core.c
81361 +++ b/kernel/debug/debug_core.c
81362 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
81363 */
81364 static atomic_t masters_in_kgdb;
81365 static atomic_t slaves_in_kgdb;
81366 -static atomic_t kgdb_break_tasklet_var;
81367 +static atomic_unchecked_t kgdb_break_tasklet_var;
81368 atomic_t kgdb_setting_breakpoint;
81369
81370 struct task_struct *kgdb_usethread;
81371 @@ -133,7 +133,7 @@ int kgdb_single_step;
81372 static pid_t kgdb_sstep_pid;
81373
81374 /* to keep track of the CPU which is doing the single stepping*/
81375 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81376 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81377
81378 /*
81379 * If you are debugging a problem where roundup (the collection of
81380 @@ -541,7 +541,7 @@ return_normal:
81381 * kernel will only try for the value of sstep_tries before
81382 * giving up and continuing on.
81383 */
81384 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81385 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81386 (kgdb_info[cpu].task &&
81387 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81388 atomic_set(&kgdb_active, -1);
81389 @@ -635,8 +635,8 @@ cpu_master_loop:
81390 }
81391
81392 kgdb_restore:
81393 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81394 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81395 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81396 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81397 if (kgdb_info[sstep_cpu].task)
81398 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81399 else
81400 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81401 static void kgdb_tasklet_bpt(unsigned long ing)
81402 {
81403 kgdb_breakpoint();
81404 - atomic_set(&kgdb_break_tasklet_var, 0);
81405 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81406 }
81407
81408 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81409
81410 void kgdb_schedule_breakpoint(void)
81411 {
81412 - if (atomic_read(&kgdb_break_tasklet_var) ||
81413 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81414 atomic_read(&kgdb_active) != -1 ||
81415 atomic_read(&kgdb_setting_breakpoint))
81416 return;
81417 - atomic_inc(&kgdb_break_tasklet_var);
81418 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81419 tasklet_schedule(&kgdb_tasklet_breakpoint);
81420 }
81421 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81422 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81423 index 00eb8f7..d7e3244 100644
81424 --- a/kernel/debug/kdb/kdb_main.c
81425 +++ b/kernel/debug/kdb/kdb_main.c
81426 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81427 continue;
81428
81429 kdb_printf("%-20s%8u 0x%p ", mod->name,
81430 - mod->core_size, (void *)mod);
81431 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81432 #ifdef CONFIG_MODULE_UNLOAD
81433 kdb_printf("%4ld ", module_refcount(mod));
81434 #endif
81435 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81436 kdb_printf(" (Loading)");
81437 else
81438 kdb_printf(" (Live)");
81439 - kdb_printf(" 0x%p", mod->module_core);
81440 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81441
81442 #ifdef CONFIG_MODULE_UNLOAD
81443 {
81444 diff --git a/kernel/events/core.c b/kernel/events/core.c
81445 index e76e495..cbfe63a 100644
81446 --- a/kernel/events/core.c
81447 +++ b/kernel/events/core.c
81448 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
81449 * 0 - disallow raw tracepoint access for unpriv
81450 * 1 - disallow cpu events for unpriv
81451 * 2 - disallow kernel profiling for unpriv
81452 + * 3 - disallow all unpriv perf event use
81453 */
81454 -int sysctl_perf_event_paranoid __read_mostly = 1;
81455 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81456 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81457 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81458 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81459 +#else
81460 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81461 +#endif
81462
81463 /* Minimum for 512 kiB + 1 user control page */
81464 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81465 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
81466 return 0;
81467 }
81468
81469 -static atomic64_t perf_event_id;
81470 +static atomic64_unchecked_t perf_event_id;
81471
81472 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81473 enum event_type_t event_type);
81474 @@ -2747,7 +2754,7 @@ static void __perf_event_read(void *info)
81475
81476 static inline u64 perf_event_count(struct perf_event *event)
81477 {
81478 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81479 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81480 }
81481
81482 static u64 perf_event_read(struct perf_event *event)
81483 @@ -3093,9 +3100,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81484 mutex_lock(&event->child_mutex);
81485 total += perf_event_read(event);
81486 *enabled += event->total_time_enabled +
81487 - atomic64_read(&event->child_total_time_enabled);
81488 + atomic64_read_unchecked(&event->child_total_time_enabled);
81489 *running += event->total_time_running +
81490 - atomic64_read(&event->child_total_time_running);
81491 + atomic64_read_unchecked(&event->child_total_time_running);
81492
81493 list_for_each_entry(child, &event->child_list, child_list) {
81494 total += perf_event_read(child);
81495 @@ -3481,10 +3488,10 @@ void perf_event_update_userpage(struct perf_event *event)
81496 userpg->offset -= local64_read(&event->hw.prev_count);
81497
81498 userpg->time_enabled = enabled +
81499 - atomic64_read(&event->child_total_time_enabled);
81500 + atomic64_read_unchecked(&event->child_total_time_enabled);
81501
81502 userpg->time_running = running +
81503 - atomic64_read(&event->child_total_time_running);
81504 + atomic64_read_unchecked(&event->child_total_time_running);
81505
81506 arch_perf_update_userpage(userpg, now);
81507
81508 @@ -4034,7 +4041,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81509
81510 /* Data. */
81511 sp = perf_user_stack_pointer(regs);
81512 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81513 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81514 dyn_size = dump_size - rem;
81515
81516 perf_output_skip(handle, rem);
81517 @@ -4122,11 +4129,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81518 values[n++] = perf_event_count(event);
81519 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81520 values[n++] = enabled +
81521 - atomic64_read(&event->child_total_time_enabled);
81522 + atomic64_read_unchecked(&event->child_total_time_enabled);
81523 }
81524 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81525 values[n++] = running +
81526 - atomic64_read(&event->child_total_time_running);
81527 + atomic64_read_unchecked(&event->child_total_time_running);
81528 }
81529 if (read_format & PERF_FORMAT_ID)
81530 values[n++] = primary_event_id(event);
81531 @@ -4835,12 +4842,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81532 * need to add enough zero bytes after the string to handle
81533 * the 64bit alignment we do later.
81534 */
81535 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81536 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81537 if (!buf) {
81538 name = strncpy(tmp, "//enomem", sizeof(tmp));
81539 goto got_name;
81540 }
81541 - name = d_path(&file->f_path, buf, PATH_MAX);
81542 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81543 if (IS_ERR(name)) {
81544 name = strncpy(tmp, "//toolong", sizeof(tmp));
81545 goto got_name;
81546 @@ -6262,7 +6269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81547 event->parent = parent_event;
81548
81549 event->ns = get_pid_ns(task_active_pid_ns(current));
81550 - event->id = atomic64_inc_return(&perf_event_id);
81551 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81552
81553 event->state = PERF_EVENT_STATE_INACTIVE;
81554
81555 @@ -6572,6 +6579,11 @@ SYSCALL_DEFINE5(perf_event_open,
81556 if (flags & ~PERF_FLAG_ALL)
81557 return -EINVAL;
81558
81559 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81560 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81561 + return -EACCES;
81562 +#endif
81563 +
81564 err = perf_copy_attr(attr_uptr, &attr);
81565 if (err)
81566 return err;
81567 @@ -6904,10 +6916,10 @@ static void sync_child_event(struct perf_event *child_event,
81568 /*
81569 * Add back the child's count to the parent's count:
81570 */
81571 - atomic64_add(child_val, &parent_event->child_count);
81572 - atomic64_add(child_event->total_time_enabled,
81573 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81574 + atomic64_add_unchecked(child_event->total_time_enabled,
81575 &parent_event->child_total_time_enabled);
81576 - atomic64_add(child_event->total_time_running,
81577 + atomic64_add_unchecked(child_event->total_time_running,
81578 &parent_event->child_total_time_running);
81579
81580 /*
81581 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81582 index ca65997..60df03d 100644
81583 --- a/kernel/events/internal.h
81584 +++ b/kernel/events/internal.h
81585 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81586 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81587 }
81588
81589 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81590 -static inline unsigned int \
81591 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81592 +static inline unsigned long \
81593 func_name(struct perf_output_handle *handle, \
81594 - const void *buf, unsigned int len) \
81595 + const void user *buf, unsigned long len) \
81596 { \
81597 unsigned long size, written; \
81598 \
81599 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81600 return n;
81601 }
81602
81603 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81604 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81605
81606 #define MEMCPY_SKIP(dst, src, n) (n)
81607
81608 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81609 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81610
81611 #ifndef arch_perf_out_copy_user
81612 #define arch_perf_out_copy_user __copy_from_user_inatomic
81613 #endif
81614
81615 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81616 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81617
81618 /* Callchain handling */
81619 extern struct perf_callchain_entry *
81620 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81621 index f356974..cb8c570 100644
81622 --- a/kernel/events/uprobes.c
81623 +++ b/kernel/events/uprobes.c
81624 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
81625 {
81626 struct page *page;
81627 uprobe_opcode_t opcode;
81628 - int result;
81629 + long result;
81630
81631 pagefault_disable();
81632 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
81633 diff --git a/kernel/exit.c b/kernel/exit.c
81634 index 7bb73f9..d7978ed 100644
81635 --- a/kernel/exit.c
81636 +++ b/kernel/exit.c
81637 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
81638 struct task_struct *leader;
81639 int zap_leader;
81640 repeat:
81641 +#ifdef CONFIG_NET
81642 + gr_del_task_from_ip_table(p);
81643 +#endif
81644 +
81645 /* don't need to get the RCU readlock here - the process is dead and
81646 * can't be modifying its own credentials. But shut RCU-lockdep up */
81647 rcu_read_lock();
81648 @@ -340,7 +344,7 @@ int allow_signal(int sig)
81649 * know it'll be handled, so that they don't get converted to
81650 * SIGKILL or just silently dropped.
81651 */
81652 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
81653 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
81654 recalc_sigpending();
81655 spin_unlock_irq(&current->sighand->siglock);
81656 return 0;
81657 @@ -709,6 +713,8 @@ void do_exit(long code)
81658 struct task_struct *tsk = current;
81659 int group_dead;
81660
81661 + set_fs(USER_DS);
81662 +
81663 profile_task_exit(tsk);
81664
81665 WARN_ON(blk_needs_flush_plug(tsk));
81666 @@ -725,7 +731,6 @@ void do_exit(long code)
81667 * mm_release()->clear_child_tid() from writing to a user-controlled
81668 * kernel address.
81669 */
81670 - set_fs(USER_DS);
81671
81672 ptrace_event(PTRACE_EVENT_EXIT, code);
81673
81674 @@ -784,6 +789,9 @@ void do_exit(long code)
81675 tsk->exit_code = code;
81676 taskstats_exit(tsk, group_dead);
81677
81678 + gr_acl_handle_psacct(tsk, code);
81679 + gr_acl_handle_exit();
81680 +
81681 exit_mm(tsk);
81682
81683 if (group_dead)
81684 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
81685 * Take down every thread in the group. This is called by fatal signals
81686 * as well as by sys_exit_group (below).
81687 */
81688 -void
81689 +__noreturn void
81690 do_group_exit(int exit_code)
81691 {
81692 struct signal_struct *sig = current->signal;
81693 diff --git a/kernel/fork.c b/kernel/fork.c
81694 index ffbc090..08ceeee 100644
81695 --- a/kernel/fork.c
81696 +++ b/kernel/fork.c
81697 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
81698 *stackend = STACK_END_MAGIC; /* for overflow detection */
81699
81700 #ifdef CONFIG_CC_STACKPROTECTOR
81701 - tsk->stack_canary = get_random_int();
81702 + tsk->stack_canary = pax_get_random_long();
81703 #endif
81704
81705 /*
81706 @@ -345,13 +345,81 @@ free_tsk:
81707 }
81708
81709 #ifdef CONFIG_MMU
81710 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
81711 +{
81712 + struct vm_area_struct *tmp;
81713 + unsigned long charge;
81714 + struct mempolicy *pol;
81715 + struct file *file;
81716 +
81717 + charge = 0;
81718 + if (mpnt->vm_flags & VM_ACCOUNT) {
81719 + unsigned long len = vma_pages(mpnt);
81720 +
81721 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81722 + goto fail_nomem;
81723 + charge = len;
81724 + }
81725 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81726 + if (!tmp)
81727 + goto fail_nomem;
81728 + *tmp = *mpnt;
81729 + tmp->vm_mm = mm;
81730 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
81731 + pol = mpol_dup(vma_policy(mpnt));
81732 + if (IS_ERR(pol))
81733 + goto fail_nomem_policy;
81734 + vma_set_policy(tmp, pol);
81735 + if (anon_vma_fork(tmp, mpnt))
81736 + goto fail_nomem_anon_vma_fork;
81737 + tmp->vm_flags &= ~VM_LOCKED;
81738 + tmp->vm_next = tmp->vm_prev = NULL;
81739 + tmp->vm_mirror = NULL;
81740 + file = tmp->vm_file;
81741 + if (file) {
81742 + struct inode *inode = file_inode(file);
81743 + struct address_space *mapping = file->f_mapping;
81744 +
81745 + get_file(file);
81746 + if (tmp->vm_flags & VM_DENYWRITE)
81747 + atomic_dec(&inode->i_writecount);
81748 + mutex_lock(&mapping->i_mmap_mutex);
81749 + if (tmp->vm_flags & VM_SHARED)
81750 + mapping->i_mmap_writable++;
81751 + flush_dcache_mmap_lock(mapping);
81752 + /* insert tmp into the share list, just after mpnt */
81753 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81754 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
81755 + else
81756 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
81757 + flush_dcache_mmap_unlock(mapping);
81758 + mutex_unlock(&mapping->i_mmap_mutex);
81759 + }
81760 +
81761 + /*
81762 + * Clear hugetlb-related page reserves for children. This only
81763 + * affects MAP_PRIVATE mappings. Faults generated by the child
81764 + * are not guaranteed to succeed, even if read-only
81765 + */
81766 + if (is_vm_hugetlb_page(tmp))
81767 + reset_vma_resv_huge_pages(tmp);
81768 +
81769 + return tmp;
81770 +
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 + vm_unacct_memory(charge);
81777 + return NULL;
81778 +}
81779 +
81780 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81781 {
81782 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
81783 struct rb_node **rb_link, *rb_parent;
81784 int retval;
81785 - unsigned long charge;
81786 - struct mempolicy *pol;
81787
81788 uprobe_start_dup_mmap();
81789 down_write(&oldmm->mmap_sem);
81790 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81791 mm->locked_vm = 0;
81792 mm->mmap = NULL;
81793 mm->mmap_cache = NULL;
81794 - mm->free_area_cache = oldmm->mmap_base;
81795 - mm->cached_hole_size = ~0UL;
81796 + mm->free_area_cache = oldmm->free_area_cache;
81797 + mm->cached_hole_size = oldmm->cached_hole_size;
81798 mm->map_count = 0;
81799 cpumask_clear(mm_cpumask(mm));
81800 mm->mm_rb = RB_ROOT;
81801 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81802
81803 prev = NULL;
81804 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
81805 - struct file *file;
81806 -
81807 if (mpnt->vm_flags & VM_DONTCOPY) {
81808 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
81809 -vma_pages(mpnt));
81810 continue;
81811 }
81812 - charge = 0;
81813 - if (mpnt->vm_flags & VM_ACCOUNT) {
81814 - unsigned long len = vma_pages(mpnt);
81815 -
81816 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81817 - goto fail_nomem;
81818 - charge = len;
81819 - }
81820 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81821 - if (!tmp)
81822 - goto fail_nomem;
81823 - *tmp = *mpnt;
81824 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
81825 - pol = mpol_dup(vma_policy(mpnt));
81826 - retval = PTR_ERR(pol);
81827 - if (IS_ERR(pol))
81828 - goto fail_nomem_policy;
81829 - vma_set_policy(tmp, pol);
81830 - tmp->vm_mm = mm;
81831 - if (anon_vma_fork(tmp, mpnt))
81832 - goto fail_nomem_anon_vma_fork;
81833 - tmp->vm_flags &= ~VM_LOCKED;
81834 - tmp->vm_next = tmp->vm_prev = NULL;
81835 - file = tmp->vm_file;
81836 - if (file) {
81837 - struct inode *inode = file_inode(file);
81838 - struct address_space *mapping = file->f_mapping;
81839 -
81840 - get_file(file);
81841 - if (tmp->vm_flags & VM_DENYWRITE)
81842 - atomic_dec(&inode->i_writecount);
81843 - mutex_lock(&mapping->i_mmap_mutex);
81844 - if (tmp->vm_flags & VM_SHARED)
81845 - mapping->i_mmap_writable++;
81846 - flush_dcache_mmap_lock(mapping);
81847 - /* insert tmp into the share list, just after mpnt */
81848 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81849 - vma_nonlinear_insert(tmp,
81850 - &mapping->i_mmap_nonlinear);
81851 - else
81852 - vma_interval_tree_insert_after(tmp, mpnt,
81853 - &mapping->i_mmap);
81854 - flush_dcache_mmap_unlock(mapping);
81855 - mutex_unlock(&mapping->i_mmap_mutex);
81856 + tmp = dup_vma(mm, oldmm, mpnt);
81857 + if (!tmp) {
81858 + retval = -ENOMEM;
81859 + goto out;
81860 }
81861
81862 /*
81863 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81864 if (retval)
81865 goto out;
81866 }
81867 +
81868 +#ifdef CONFIG_PAX_SEGMEXEC
81869 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
81870 + struct vm_area_struct *mpnt_m;
81871 +
81872 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
81873 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
81874 +
81875 + if (!mpnt->vm_mirror)
81876 + continue;
81877 +
81878 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
81879 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
81880 + mpnt->vm_mirror = mpnt_m;
81881 + } else {
81882 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
81883 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
81884 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
81885 + mpnt->vm_mirror->vm_mirror = mpnt;
81886 + }
81887 + }
81888 + BUG_ON(mpnt_m);
81889 + }
81890 +#endif
81891 +
81892 /* a new mm has just been created */
81893 arch_dup_mmap(oldmm, mm);
81894 retval = 0;
81895 @@ -473,14 +524,6 @@ out:
81896 up_write(&oldmm->mmap_sem);
81897 uprobe_end_dup_mmap();
81898 return retval;
81899 -fail_nomem_anon_vma_fork:
81900 - mpol_put(pol);
81901 -fail_nomem_policy:
81902 - kmem_cache_free(vm_area_cachep, tmp);
81903 -fail_nomem:
81904 - retval = -ENOMEM;
81905 - vm_unacct_memory(charge);
81906 - goto out;
81907 }
81908
81909 static inline int mm_alloc_pgd(struct mm_struct *mm)
81910 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
81911 return ERR_PTR(err);
81912
81913 mm = get_task_mm(task);
81914 - if (mm && mm != current->mm &&
81915 - !ptrace_may_access(task, mode)) {
81916 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
81917 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
81918 mmput(mm);
81919 mm = ERR_PTR(-EACCES);
81920 }
81921 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
81922 spin_unlock(&fs->lock);
81923 return -EAGAIN;
81924 }
81925 - fs->users++;
81926 + atomic_inc(&fs->users);
81927 spin_unlock(&fs->lock);
81928 return 0;
81929 }
81930 tsk->fs = copy_fs_struct(fs);
81931 if (!tsk->fs)
81932 return -ENOMEM;
81933 + /* Carry through gr_chroot_dentry and is_chrooted instead
81934 + of recomputing it here. Already copied when the task struct
81935 + is duplicated. This allows pivot_root to not be treated as
81936 + a chroot
81937 + */
81938 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
81939 +
81940 return 0;
81941 }
81942
81943 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81944 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
81945 #endif
81946 retval = -EAGAIN;
81947 +
81948 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
81949 +
81950 if (atomic_read(&p->real_cred->user->processes) >=
81951 task_rlimit(p, RLIMIT_NPROC)) {
81952 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
81953 - p->real_cred->user != INIT_USER)
81954 + if (p->real_cred->user != INIT_USER &&
81955 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
81956 goto bad_fork_free;
81957 }
81958 current->flags &= ~PF_NPROC_EXCEEDED;
81959 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81960 goto bad_fork_free_pid;
81961 }
81962
81963 + /* synchronizes with gr_set_acls()
81964 + we need to call this past the point of no return for fork()
81965 + */
81966 + gr_copy_label(p);
81967 +
81968 if (clone_flags & CLONE_THREAD) {
81969 current->signal->nr_threads++;
81970 atomic_inc(&current->signal->live);
81971 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
81972 bad_fork_free:
81973 free_task(p);
81974 fork_out:
81975 + gr_log_forkfail(retval);
81976 +
81977 return ERR_PTR(retval);
81978 }
81979
81980 @@ -1613,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
81981 if (clone_flags & CLONE_PARENT_SETTID)
81982 put_user(nr, parent_tidptr);
81983
81984 + gr_handle_brute_check();
81985 +
81986 if (clone_flags & CLONE_VFORK) {
81987 p->vfork_done = &vfork;
81988 init_completion(&vfork);
81989 @@ -1729,7 +1791,7 @@ void __init proc_caches_init(void)
81990 mm_cachep = kmem_cache_create("mm_struct",
81991 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81992 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81993 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81994 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81995 mmap_init();
81996 nsproxy_cache_init();
81997 }
81998 @@ -1769,7 +1831,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81999 return 0;
82000
82001 /* don't need lock here; in the worst case we'll do useless copy */
82002 - if (fs->users == 1)
82003 + if (atomic_read(&fs->users) == 1)
82004 return 0;
82005
82006 *new_fsp = copy_fs_struct(fs);
82007 @@ -1881,7 +1943,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
82008 fs = current->fs;
82009 spin_lock(&fs->lock);
82010 current->fs = new_fs;
82011 - if (--fs->users)
82012 + gr_set_chroot_entries(current, &current->fs->root);
82013 + if (atomic_dec_return(&fs->users))
82014 new_fs = NULL;
82015 else
82016 new_fs = fs;
82017 diff --git a/kernel/futex.c b/kernel/futex.c
82018 index 49dacfb..2ac4526 100644
82019 --- a/kernel/futex.c
82020 +++ b/kernel/futex.c
82021 @@ -54,6 +54,7 @@
82022 #include <linux/mount.h>
82023 #include <linux/pagemap.h>
82024 #include <linux/syscalls.h>
82025 +#include <linux/ptrace.h>
82026 #include <linux/signal.h>
82027 #include <linux/export.h>
82028 #include <linux/magic.h>
82029 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
82030 struct page *page, *page_head;
82031 int err, ro = 0;
82032
82033 +#ifdef CONFIG_PAX_SEGMEXEC
82034 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
82035 + return -EFAULT;
82036 +#endif
82037 +
82038 /*
82039 * The futex address must be "naturally" aligned.
82040 */
82041 @@ -440,7 +446,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
82042
82043 static int get_futex_value_locked(u32 *dest, u32 __user *from)
82044 {
82045 - int ret;
82046 + unsigned long ret;
82047
82048 pagefault_disable();
82049 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
82050 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
82051 {
82052 u32 curval;
82053 int i;
82054 + mm_segment_t oldfs;
82055
82056 /*
82057 * This will fail and we want it. Some arch implementations do
82058 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
82059 * implementation, the non-functional ones will return
82060 * -ENOSYS.
82061 */
82062 + oldfs = get_fs();
82063 + set_fs(USER_DS);
82064 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
82065 futex_cmpxchg_enabled = 1;
82066 + set_fs(oldfs);
82067
82068 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
82069 plist_head_init(&futex_queues[i].chain);
82070 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
82071 index f9f44fd..29885e4 100644
82072 --- a/kernel/futex_compat.c
82073 +++ b/kernel/futex_compat.c
82074 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
82075 return 0;
82076 }
82077
82078 -static void __user *futex_uaddr(struct robust_list __user *entry,
82079 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
82080 compat_long_t futex_offset)
82081 {
82082 compat_uptr_t base = ptr_to_compat(entry);
82083 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
82084 index 9b22d03..6295b62 100644
82085 --- a/kernel/gcov/base.c
82086 +++ b/kernel/gcov/base.c
82087 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
82088 }
82089
82090 #ifdef CONFIG_MODULES
82091 -static inline int within(void *addr, void *start, unsigned long size)
82092 -{
82093 - return ((addr >= start) && (addr < start + size));
82094 -}
82095 -
82096 /* Update list and generate events when modules are unloaded. */
82097 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82098 void *data)
82099 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82100 prev = NULL;
82101 /* Remove entries located in module from linked list. */
82102 for (info = gcov_info_head; info; info = info->next) {
82103 - if (within(info, mod->module_core, mod->core_size)) {
82104 + if (within_module_core_rw((unsigned long)info, mod)) {
82105 if (prev)
82106 prev->next = info->next;
82107 else
82108 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
82109 index 2288fbd..0f3941f 100644
82110 --- a/kernel/hrtimer.c
82111 +++ b/kernel/hrtimer.c
82112 @@ -1435,7 +1435,7 @@ void hrtimer_peek_ahead_timers(void)
82113 local_irq_restore(flags);
82114 }
82115
82116 -static void run_hrtimer_softirq(struct softirq_action *h)
82117 +static void run_hrtimer_softirq(void)
82118 {
82119 hrtimer_peek_ahead_timers();
82120 }
82121 @@ -1770,7 +1770,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
82122 return NOTIFY_OK;
82123 }
82124
82125 -static struct notifier_block __cpuinitdata hrtimers_nb = {
82126 +static struct notifier_block hrtimers_nb = {
82127 .notifier_call = hrtimer_cpu_notify,
82128 };
82129
82130 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
82131 index 55fcce6..0e4cf34 100644
82132 --- a/kernel/irq_work.c
82133 +++ b/kernel/irq_work.c
82134 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
82135 return NOTIFY_OK;
82136 }
82137
82138 -static struct notifier_block cpu_notify;
82139 +static struct notifier_block cpu_notify = {
82140 + .notifier_call = irq_work_cpu_notify,
82141 + .priority = 0,
82142 +};
82143
82144 static __init int irq_work_init_cpu_notifier(void)
82145 {
82146 - cpu_notify.notifier_call = irq_work_cpu_notify;
82147 - cpu_notify.priority = 0;
82148 register_cpu_notifier(&cpu_notify);
82149 return 0;
82150 }
82151 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
82152 index 60f48fa..7f3a770 100644
82153 --- a/kernel/jump_label.c
82154 +++ b/kernel/jump_label.c
82155 @@ -13,6 +13,7 @@
82156 #include <linux/sort.h>
82157 #include <linux/err.h>
82158 #include <linux/static_key.h>
82159 +#include <linux/mm.h>
82160
82161 #ifdef HAVE_JUMP_LABEL
82162
82163 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
82164
82165 size = (((unsigned long)stop - (unsigned long)start)
82166 / sizeof(struct jump_entry));
82167 + pax_open_kernel();
82168 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
82169 + pax_close_kernel();
82170 }
82171
82172 static void jump_label_update(struct static_key *key, int enable);
82173 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
82174 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
82175 struct jump_entry *iter;
82176
82177 + pax_open_kernel();
82178 for (iter = iter_start; iter < iter_stop; iter++) {
82179 if (within_module_init(iter->code, mod))
82180 iter->code = 0;
82181 }
82182 + pax_close_kernel();
82183 }
82184
82185 static int
82186 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
82187 index 3127ad5..159d880 100644
82188 --- a/kernel/kallsyms.c
82189 +++ b/kernel/kallsyms.c
82190 @@ -11,6 +11,9 @@
82191 * Changed the compression method from stem compression to "table lookup"
82192 * compression (see scripts/kallsyms.c for a more complete description)
82193 */
82194 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82195 +#define __INCLUDED_BY_HIDESYM 1
82196 +#endif
82197 #include <linux/kallsyms.h>
82198 #include <linux/module.h>
82199 #include <linux/init.h>
82200 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
82201
82202 static inline int is_kernel_inittext(unsigned long addr)
82203 {
82204 + if (system_state != SYSTEM_BOOTING)
82205 + return 0;
82206 +
82207 if (addr >= (unsigned long)_sinittext
82208 && addr <= (unsigned long)_einittext)
82209 return 1;
82210 return 0;
82211 }
82212
82213 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82214 +#ifdef CONFIG_MODULES
82215 +static inline int is_module_text(unsigned long addr)
82216 +{
82217 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
82218 + return 1;
82219 +
82220 + addr = ktla_ktva(addr);
82221 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
82222 +}
82223 +#else
82224 +static inline int is_module_text(unsigned long addr)
82225 +{
82226 + return 0;
82227 +}
82228 +#endif
82229 +#endif
82230 +
82231 static inline int is_kernel_text(unsigned long addr)
82232 {
82233 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
82234 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
82235
82236 static inline int is_kernel(unsigned long addr)
82237 {
82238 +
82239 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82240 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
82241 + return 1;
82242 +
82243 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
82244 +#else
82245 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
82246 +#endif
82247 +
82248 return 1;
82249 return in_gate_area_no_mm(addr);
82250 }
82251
82252 static int is_ksym_addr(unsigned long addr)
82253 {
82254 +
82255 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82256 + if (is_module_text(addr))
82257 + return 0;
82258 +#endif
82259 +
82260 if (all_var)
82261 return is_kernel(addr);
82262
82263 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
82264
82265 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
82266 {
82267 - iter->name[0] = '\0';
82268 iter->nameoff = get_symbol_offset(new_pos);
82269 iter->pos = new_pos;
82270 }
82271 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
82272 {
82273 struct kallsym_iter *iter = m->private;
82274
82275 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82276 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
82277 + return 0;
82278 +#endif
82279 +
82280 /* Some debugging symbols have no name. Ignore them. */
82281 if (!iter->name[0])
82282 return 0;
82283 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
82284 */
82285 type = iter->exported ? toupper(iter->type) :
82286 tolower(iter->type);
82287 +
82288 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
82289 type, iter->name, iter->module_name);
82290 } else
82291 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
82292 struct kallsym_iter *iter;
82293 int ret;
82294
82295 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
82296 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
82297 if (!iter)
82298 return -ENOMEM;
82299 reset_iter(iter, 0);
82300 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
82301 index e30ac0f..3528cac 100644
82302 --- a/kernel/kcmp.c
82303 +++ b/kernel/kcmp.c
82304 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
82305 struct task_struct *task1, *task2;
82306 int ret;
82307
82308 +#ifdef CONFIG_GRKERNSEC
82309 + return -ENOSYS;
82310 +#endif
82311 +
82312 rcu_read_lock();
82313
82314 /*
82315 diff --git a/kernel/kexec.c b/kernel/kexec.c
82316 index 59f7b55..4022f65 100644
82317 --- a/kernel/kexec.c
82318 +++ b/kernel/kexec.c
82319 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
82320 unsigned long flags)
82321 {
82322 struct compat_kexec_segment in;
82323 - struct kexec_segment out, __user *ksegments;
82324 + struct kexec_segment out;
82325 + struct kexec_segment __user *ksegments;
82326 unsigned long i, result;
82327
82328 /* Don't allow clients that don't understand the native
82329 diff --git a/kernel/kmod.c b/kernel/kmod.c
82330 index 8241906..d625f2c 100644
82331 --- a/kernel/kmod.c
82332 +++ b/kernel/kmod.c
82333 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
82334 kfree(info->argv);
82335 }
82336
82337 -static int call_modprobe(char *module_name, int wait)
82338 +static int call_modprobe(char *module_name, char *module_param, int wait)
82339 {
82340 struct subprocess_info *info;
82341 static char *envp[] = {
82342 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
82343 NULL
82344 };
82345
82346 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
82347 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
82348 if (!argv)
82349 goto out;
82350
82351 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
82352 argv[1] = "-q";
82353 argv[2] = "--";
82354 argv[3] = module_name; /* check free_modprobe_argv() */
82355 - argv[4] = NULL;
82356 + argv[4] = module_param;
82357 + argv[5] = NULL;
82358
82359 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
82360 NULL, free_modprobe_argv, NULL);
82361 @@ -129,9 +130,8 @@ out:
82362 * If module auto-loading support is disabled then this function
82363 * becomes a no-operation.
82364 */
82365 -int __request_module(bool wait, const char *fmt, ...)
82366 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
82367 {
82368 - va_list args;
82369 char module_name[MODULE_NAME_LEN];
82370 unsigned int max_modprobes;
82371 int ret;
82372 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
82373 */
82374 WARN_ON_ONCE(wait && current_is_async());
82375
82376 - va_start(args, fmt);
82377 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82378 - va_end(args);
82379 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82380 if (ret >= MODULE_NAME_LEN)
82381 return -ENAMETOOLONG;
82382
82383 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
82384 if (ret)
82385 return ret;
82386
82387 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82388 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82389 + /* hack to workaround consolekit/udisks stupidity */
82390 + read_lock(&tasklist_lock);
82391 + if (!strcmp(current->comm, "mount") &&
82392 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82393 + read_unlock(&tasklist_lock);
82394 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82395 + return -EPERM;
82396 + }
82397 + read_unlock(&tasklist_lock);
82398 + }
82399 +#endif
82400 +
82401 /* If modprobe needs a service that is in a module, we get a recursive
82402 * loop. Limit the number of running kmod threads to max_threads/2 or
82403 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82404 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
82405
82406 trace_module_request(module_name, wait, _RET_IP_);
82407
82408 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82409 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82410
82411 atomic_dec(&kmod_concurrent);
82412 return ret;
82413 }
82414 +
82415 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82416 +{
82417 + va_list args;
82418 + int ret;
82419 +
82420 + va_start(args, fmt);
82421 + ret = ____request_module(wait, module_param, fmt, args);
82422 + va_end(args);
82423 +
82424 + return ret;
82425 +}
82426 +
82427 +int __request_module(bool wait, const char *fmt, ...)
82428 +{
82429 + va_list args;
82430 + int ret;
82431 +
82432 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82433 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82434 + char module_param[MODULE_NAME_LEN];
82435 +
82436 + memset(module_param, 0, sizeof(module_param));
82437 +
82438 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82439 +
82440 + va_start(args, fmt);
82441 + ret = ____request_module(wait, module_param, fmt, args);
82442 + va_end(args);
82443 +
82444 + return ret;
82445 + }
82446 +#endif
82447 +
82448 + va_start(args, fmt);
82449 + ret = ____request_module(wait, NULL, fmt, args);
82450 + va_end(args);
82451 +
82452 + return ret;
82453 +}
82454 +
82455 EXPORT_SYMBOL(__request_module);
82456 #endif /* CONFIG_MODULES */
82457
82458 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
82459 *
82460 * Thus the __user pointer cast is valid here.
82461 */
82462 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82463 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82464
82465 /*
82466 * If ret is 0, either ____call_usermodehelper failed and the
82467 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82468 static int proc_cap_handler(struct ctl_table *table, int write,
82469 void __user *buffer, size_t *lenp, loff_t *ppos)
82470 {
82471 - struct ctl_table t;
82472 + ctl_table_no_const t;
82473 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82474 kernel_cap_t new_cap;
82475 int err, i;
82476 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82477 index bddf3b2..233bf40 100644
82478 --- a/kernel/kprobes.c
82479 +++ b/kernel/kprobes.c
82480 @@ -31,6 +31,9 @@
82481 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82482 * <prasanna@in.ibm.com> added function-return probes.
82483 */
82484 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82485 +#define __INCLUDED_BY_HIDESYM 1
82486 +#endif
82487 #include <linux/kprobes.h>
82488 #include <linux/hash.h>
82489 #include <linux/init.h>
82490 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
82491 * kernel image and loaded module images reside. This is required
82492 * so x86_64 can correctly handle the %rip-relative fixups.
82493 */
82494 - kip->insns = module_alloc(PAGE_SIZE);
82495 + kip->insns = module_alloc_exec(PAGE_SIZE);
82496 if (!kip->insns) {
82497 kfree(kip);
82498 return NULL;
82499 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
82500 */
82501 if (!list_is_singular(&kip->list)) {
82502 list_del(&kip->list);
82503 - module_free(NULL, kip->insns);
82504 + module_free_exec(NULL, kip->insns);
82505 kfree(kip);
82506 }
82507 return 1;
82508 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
82509 {
82510 int i, err = 0;
82511 unsigned long offset = 0, size = 0;
82512 - char *modname, namebuf[128];
82513 + char *modname, namebuf[KSYM_NAME_LEN];
82514 const char *symbol_name;
82515 void *addr;
82516 struct kprobe_blackpoint *kb;
82517 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82518 kprobe_type = "k";
82519
82520 if (sym)
82521 - seq_printf(pi, "%p %s %s+0x%x %s ",
82522 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82523 p->addr, kprobe_type, sym, offset,
82524 (modname ? modname : " "));
82525 else
82526 - seq_printf(pi, "%p %s %p ",
82527 + seq_printf(pi, "%pK %s %pK ",
82528 p->addr, kprobe_type, p->addr);
82529
82530 if (!pp)
82531 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82532 const char *sym = NULL;
82533 unsigned int i = *(loff_t *) v;
82534 unsigned long offset = 0;
82535 - char *modname, namebuf[128];
82536 + char *modname, namebuf[KSYM_NAME_LEN];
82537
82538 head = &kprobe_table[i];
82539 preempt_disable();
82540 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82541 index 6ada93c..dce7d5d 100644
82542 --- a/kernel/ksysfs.c
82543 +++ b/kernel/ksysfs.c
82544 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82545 {
82546 if (count+1 > UEVENT_HELPER_PATH_LEN)
82547 return -ENOENT;
82548 + if (!capable(CAP_SYS_ADMIN))
82549 + return -EPERM;
82550 memcpy(uevent_helper, buf, count);
82551 uevent_helper[count] = '\0';
82552 if (count && uevent_helper[count-1] == '\n')
82553 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82554 return count;
82555 }
82556
82557 -static struct bin_attribute notes_attr = {
82558 +static bin_attribute_no_const notes_attr __read_only = {
82559 .attr = {
82560 .name = "notes",
82561 .mode = S_IRUGO,
82562 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82563 index 1f3186b..bb7dbc6 100644
82564 --- a/kernel/lockdep.c
82565 +++ b/kernel/lockdep.c
82566 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82567 end = (unsigned long) &_end,
82568 addr = (unsigned long) obj;
82569
82570 +#ifdef CONFIG_PAX_KERNEXEC
82571 + start = ktla_ktva(start);
82572 +#endif
82573 +
82574 /*
82575 * static variable?
82576 */
82577 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82578 if (!static_obj(lock->key)) {
82579 debug_locks_off();
82580 printk("INFO: trying to register non-static key.\n");
82581 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82582 printk("the code is fine but needs lockdep annotation.\n");
82583 printk("turning off the locking correctness validator.\n");
82584 dump_stack();
82585 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82586 if (!class)
82587 return 0;
82588 }
82589 - atomic_inc((atomic_t *)&class->ops);
82590 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82591 if (very_verbose(class)) {
82592 printk("\nacquire class [%p] %s", class->key, class->name);
82593 if (class->name_version > 1)
82594 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
82595 index b2c71c5..7b88d63 100644
82596 --- a/kernel/lockdep_proc.c
82597 +++ b/kernel/lockdep_proc.c
82598 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
82599 return 0;
82600 }
82601
82602 - seq_printf(m, "%p", class->key);
82603 + seq_printf(m, "%pK", class->key);
82604 #ifdef CONFIG_DEBUG_LOCKDEP
82605 seq_printf(m, " OPS:%8ld", class->ops);
82606 #endif
82607 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
82608
82609 list_for_each_entry(entry, &class->locks_after, entry) {
82610 if (entry->distance == 1) {
82611 - seq_printf(m, " -> [%p] ", entry->class->key);
82612 + seq_printf(m, " -> [%pK] ", entry->class->key);
82613 print_name(m, entry->class);
82614 seq_puts(m, "\n");
82615 }
82616 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
82617 if (!class->key)
82618 continue;
82619
82620 - seq_printf(m, "[%p] ", class->key);
82621 + seq_printf(m, "[%pK] ", class->key);
82622 print_name(m, class);
82623 seq_puts(m, "\n");
82624 }
82625 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82626 if (!i)
82627 seq_line(m, '-', 40-namelen, namelen);
82628
82629 - snprintf(ip, sizeof(ip), "[<%p>]",
82630 + snprintf(ip, sizeof(ip), "[<%pK>]",
82631 (void *)class->contention_point[i]);
82632 seq_printf(m, "%40s %14lu %29s %pS\n",
82633 name, stats->contention_point[i],
82634 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82635 if (!i)
82636 seq_line(m, '-', 40-namelen, namelen);
82637
82638 - snprintf(ip, sizeof(ip), "[<%p>]",
82639 + snprintf(ip, sizeof(ip), "[<%pK>]",
82640 (void *)class->contending_point[i]);
82641 seq_printf(m, "%40s %14lu %29s %pS\n",
82642 name, stats->contending_point[i],
82643 diff --git a/kernel/module.c b/kernel/module.c
82644 index fa53db8..6f17200 100644
82645 --- a/kernel/module.c
82646 +++ b/kernel/module.c
82647 @@ -61,6 +61,7 @@
82648 #include <linux/pfn.h>
82649 #include <linux/bsearch.h>
82650 #include <linux/fips.h>
82651 +#include <linux/grsecurity.h>
82652 #include <uapi/linux/module.h>
82653 #include "module-internal.h"
82654
82655 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
82656
82657 /* Bounds of module allocation, for speeding __module_address.
82658 * Protected by module_mutex. */
82659 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
82660 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
82661 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
82662
82663 int register_module_notifier(struct notifier_block * nb)
82664 {
82665 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82666 return true;
82667
82668 list_for_each_entry_rcu(mod, &modules, list) {
82669 - struct symsearch arr[] = {
82670 + struct symsearch modarr[] = {
82671 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
82672 NOT_GPL_ONLY, false },
82673 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
82674 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82675 if (mod->state == MODULE_STATE_UNFORMED)
82676 continue;
82677
82678 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
82679 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
82680 return true;
82681 }
82682 return false;
82683 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
82684 static int percpu_modalloc(struct module *mod,
82685 unsigned long size, unsigned long align)
82686 {
82687 - if (align > PAGE_SIZE) {
82688 + if (align-1 >= PAGE_SIZE) {
82689 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
82690 mod->name, align, PAGE_SIZE);
82691 align = PAGE_SIZE;
82692 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
82693 static ssize_t show_coresize(struct module_attribute *mattr,
82694 struct module_kobject *mk, char *buffer)
82695 {
82696 - return sprintf(buffer, "%u\n", mk->mod->core_size);
82697 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
82698 }
82699
82700 static struct module_attribute modinfo_coresize =
82701 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
82702 static ssize_t show_initsize(struct module_attribute *mattr,
82703 struct module_kobject *mk, char *buffer)
82704 {
82705 - return sprintf(buffer, "%u\n", mk->mod->init_size);
82706 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
82707 }
82708
82709 static struct module_attribute modinfo_initsize =
82710 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
82711 */
82712 #ifdef CONFIG_SYSFS
82713
82714 -#ifdef CONFIG_KALLSYMS
82715 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82716 static inline bool sect_empty(const Elf_Shdr *sect)
82717 {
82718 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
82719 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
82720 {
82721 unsigned int notes, loaded, i;
82722 struct module_notes_attrs *notes_attrs;
82723 - struct bin_attribute *nattr;
82724 + bin_attribute_no_const *nattr;
82725
82726 /* failed to create section attributes, so can't create notes */
82727 if (!mod->sect_attrs)
82728 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
82729 static int module_add_modinfo_attrs(struct module *mod)
82730 {
82731 struct module_attribute *attr;
82732 - struct module_attribute *temp_attr;
82733 + module_attribute_no_const *temp_attr;
82734 int error = 0;
82735 int i;
82736
82737 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
82738
82739 static void unset_module_core_ro_nx(struct module *mod)
82740 {
82741 - set_page_attributes(mod->module_core + mod->core_text_size,
82742 - mod->module_core + mod->core_size,
82743 + set_page_attributes(mod->module_core_rw,
82744 + mod->module_core_rw + mod->core_size_rw,
82745 set_memory_x);
82746 - set_page_attributes(mod->module_core,
82747 - mod->module_core + mod->core_ro_size,
82748 + set_page_attributes(mod->module_core_rx,
82749 + mod->module_core_rx + mod->core_size_rx,
82750 set_memory_rw);
82751 }
82752
82753 static void unset_module_init_ro_nx(struct module *mod)
82754 {
82755 - set_page_attributes(mod->module_init + mod->init_text_size,
82756 - mod->module_init + mod->init_size,
82757 + set_page_attributes(mod->module_init_rw,
82758 + mod->module_init_rw + mod->init_size_rw,
82759 set_memory_x);
82760 - set_page_attributes(mod->module_init,
82761 - mod->module_init + mod->init_ro_size,
82762 + set_page_attributes(mod->module_init_rx,
82763 + mod->module_init_rx + mod->init_size_rx,
82764 set_memory_rw);
82765 }
82766
82767 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
82768 list_for_each_entry_rcu(mod, &modules, list) {
82769 if (mod->state == MODULE_STATE_UNFORMED)
82770 continue;
82771 - if ((mod->module_core) && (mod->core_text_size)) {
82772 - set_page_attributes(mod->module_core,
82773 - mod->module_core + mod->core_text_size,
82774 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82775 + set_page_attributes(mod->module_core_rx,
82776 + mod->module_core_rx + mod->core_size_rx,
82777 set_memory_rw);
82778 }
82779 - if ((mod->module_init) && (mod->init_text_size)) {
82780 - set_page_attributes(mod->module_init,
82781 - mod->module_init + mod->init_text_size,
82782 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82783 + set_page_attributes(mod->module_init_rx,
82784 + mod->module_init_rx + mod->init_size_rx,
82785 set_memory_rw);
82786 }
82787 }
82788 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
82789 list_for_each_entry_rcu(mod, &modules, list) {
82790 if (mod->state == MODULE_STATE_UNFORMED)
82791 continue;
82792 - if ((mod->module_core) && (mod->core_text_size)) {
82793 - set_page_attributes(mod->module_core,
82794 - mod->module_core + mod->core_text_size,
82795 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82796 + set_page_attributes(mod->module_core_rx,
82797 + mod->module_core_rx + mod->core_size_rx,
82798 set_memory_ro);
82799 }
82800 - if ((mod->module_init) && (mod->init_text_size)) {
82801 - set_page_attributes(mod->module_init,
82802 - mod->module_init + mod->init_text_size,
82803 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82804 + set_page_attributes(mod->module_init_rx,
82805 + mod->module_init_rx + mod->init_size_rx,
82806 set_memory_ro);
82807 }
82808 }
82809 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
82810
82811 /* This may be NULL, but that's OK */
82812 unset_module_init_ro_nx(mod);
82813 - module_free(mod, mod->module_init);
82814 + module_free(mod, mod->module_init_rw);
82815 + module_free_exec(mod, mod->module_init_rx);
82816 kfree(mod->args);
82817 percpu_modfree(mod);
82818
82819 /* Free lock-classes: */
82820 - lockdep_free_key_range(mod->module_core, mod->core_size);
82821 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
82822 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
82823
82824 /* Finally, free the core (containing the module structure) */
82825 unset_module_core_ro_nx(mod);
82826 - module_free(mod, mod->module_core);
82827 + module_free_exec(mod, mod->module_core_rx);
82828 + module_free(mod, mod->module_core_rw);
82829
82830 #ifdef CONFIG_MPU
82831 update_protections(current->mm);
82832 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82833 int ret = 0;
82834 const struct kernel_symbol *ksym;
82835
82836 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82837 + int is_fs_load = 0;
82838 + int register_filesystem_found = 0;
82839 + char *p;
82840 +
82841 + p = strstr(mod->args, "grsec_modharden_fs");
82842 + if (p) {
82843 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
82844 + /* copy \0 as well */
82845 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
82846 + is_fs_load = 1;
82847 + }
82848 +#endif
82849 +
82850 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
82851 const char *name = info->strtab + sym[i].st_name;
82852
82853 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82854 + /* it's a real shame this will never get ripped and copied
82855 + upstream! ;(
82856 + */
82857 + if (is_fs_load && !strcmp(name, "register_filesystem"))
82858 + register_filesystem_found = 1;
82859 +#endif
82860 +
82861 switch (sym[i].st_shndx) {
82862 case SHN_COMMON:
82863 /* We compiled with -fno-common. These are not
82864 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82865 ksym = resolve_symbol_wait(mod, info, name);
82866 /* Ok if resolved. */
82867 if (ksym && !IS_ERR(ksym)) {
82868 + pax_open_kernel();
82869 sym[i].st_value = ksym->value;
82870 + pax_close_kernel();
82871 break;
82872 }
82873
82874 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82875 secbase = (unsigned long)mod_percpu(mod);
82876 else
82877 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
82878 + pax_open_kernel();
82879 sym[i].st_value += secbase;
82880 + pax_close_kernel();
82881 break;
82882 }
82883 }
82884
82885 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82886 + if (is_fs_load && !register_filesystem_found) {
82887 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
82888 + ret = -EPERM;
82889 + }
82890 +#endif
82891 +
82892 return ret;
82893 }
82894
82895 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
82896 || s->sh_entsize != ~0UL
82897 || strstarts(sname, ".init"))
82898 continue;
82899 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
82900 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82901 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
82902 + else
82903 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
82904 pr_debug("\t%s\n", sname);
82905 }
82906 - switch (m) {
82907 - case 0: /* executable */
82908 - mod->core_size = debug_align(mod->core_size);
82909 - mod->core_text_size = mod->core_size;
82910 - break;
82911 - case 1: /* RO: text and ro-data */
82912 - mod->core_size = debug_align(mod->core_size);
82913 - mod->core_ro_size = mod->core_size;
82914 - break;
82915 - case 3: /* whole core */
82916 - mod->core_size = debug_align(mod->core_size);
82917 - break;
82918 - }
82919 }
82920
82921 pr_debug("Init section allocation order:\n");
82922 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
82923 || s->sh_entsize != ~0UL
82924 || !strstarts(sname, ".init"))
82925 continue;
82926 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
82927 - | INIT_OFFSET_MASK);
82928 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82929 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
82930 + else
82931 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
82932 + s->sh_entsize |= INIT_OFFSET_MASK;
82933 pr_debug("\t%s\n", sname);
82934 }
82935 - switch (m) {
82936 - case 0: /* executable */
82937 - mod->init_size = debug_align(mod->init_size);
82938 - mod->init_text_size = mod->init_size;
82939 - break;
82940 - case 1: /* RO: text and ro-data */
82941 - mod->init_size = debug_align(mod->init_size);
82942 - mod->init_ro_size = mod->init_size;
82943 - break;
82944 - case 3: /* whole init */
82945 - mod->init_size = debug_align(mod->init_size);
82946 - break;
82947 - }
82948 }
82949 }
82950
82951 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82952
82953 /* Put symbol section at end of init part of module. */
82954 symsect->sh_flags |= SHF_ALLOC;
82955 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82956 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82957 info->index.sym) | INIT_OFFSET_MASK;
82958 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82959
82960 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82961 }
82962
82963 /* Append room for core symbols at end of core part. */
82964 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82965 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82966 - mod->core_size += strtab_size;
82967 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82968 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82969 + mod->core_size_rx += strtab_size;
82970
82971 /* Put string table section at end of init part of module. */
82972 strsect->sh_flags |= SHF_ALLOC;
82973 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82974 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82975 info->index.str) | INIT_OFFSET_MASK;
82976 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82977 }
82978 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82979 /* Make sure we get permanent strtab: don't use info->strtab. */
82980 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82981
82982 + pax_open_kernel();
82983 +
82984 /* Set types up while we still have access to sections. */
82985 for (i = 0; i < mod->num_symtab; i++)
82986 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82987
82988 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82989 - mod->core_strtab = s = mod->module_core + info->stroffs;
82990 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82991 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82992 src = mod->symtab;
82993 for (ndst = i = 0; i < mod->num_symtab; i++) {
82994 if (i == 0 ||
82995 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82996 }
82997 }
82998 mod->core_num_syms = ndst;
82999 +
83000 + pax_close_kernel();
83001 }
83002 #else
83003 static inline void layout_symtab(struct module *mod, struct load_info *info)
83004 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
83005 return vmalloc_exec(size);
83006 }
83007
83008 -static void *module_alloc_update_bounds(unsigned long size)
83009 +static void *module_alloc_update_bounds_rw(unsigned long size)
83010 {
83011 void *ret = module_alloc(size);
83012
83013 if (ret) {
83014 mutex_lock(&module_mutex);
83015 /* Update module bounds. */
83016 - if ((unsigned long)ret < module_addr_min)
83017 - module_addr_min = (unsigned long)ret;
83018 - if ((unsigned long)ret + size > module_addr_max)
83019 - module_addr_max = (unsigned long)ret + size;
83020 + if ((unsigned long)ret < module_addr_min_rw)
83021 + module_addr_min_rw = (unsigned long)ret;
83022 + if ((unsigned long)ret + size > module_addr_max_rw)
83023 + module_addr_max_rw = (unsigned long)ret + size;
83024 + mutex_unlock(&module_mutex);
83025 + }
83026 + return ret;
83027 +}
83028 +
83029 +static void *module_alloc_update_bounds_rx(unsigned long size)
83030 +{
83031 + void *ret = module_alloc_exec(size);
83032 +
83033 + if (ret) {
83034 + mutex_lock(&module_mutex);
83035 + /* Update module bounds. */
83036 + if ((unsigned long)ret < module_addr_min_rx)
83037 + module_addr_min_rx = (unsigned long)ret;
83038 + if ((unsigned long)ret + size > module_addr_max_rx)
83039 + module_addr_max_rx = (unsigned long)ret + size;
83040 mutex_unlock(&module_mutex);
83041 }
83042 return ret;
83043 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
83044 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83045 {
83046 const char *modmagic = get_modinfo(info, "vermagic");
83047 + const char *license = get_modinfo(info, "license");
83048 int err;
83049
83050 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
83051 + if (!license || !license_is_gpl_compatible(license))
83052 + return -ENOEXEC;
83053 +#endif
83054 +
83055 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
83056 modmagic = NULL;
83057
83058 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83059 }
83060
83061 /* Set up license info based on the info section */
83062 - set_license(mod, get_modinfo(info, "license"));
83063 + set_license(mod, license);
83064
83065 return 0;
83066 }
83067 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
83068 void *ptr;
83069
83070 /* Do the allocs. */
83071 - ptr = module_alloc_update_bounds(mod->core_size);
83072 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
83073 /*
83074 * The pointer to this block is stored in the module structure
83075 * which is inside the block. Just mark it as not being a
83076 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
83077 if (!ptr)
83078 return -ENOMEM;
83079
83080 - memset(ptr, 0, mod->core_size);
83081 - mod->module_core = ptr;
83082 + memset(ptr, 0, mod->core_size_rw);
83083 + mod->module_core_rw = ptr;
83084
83085 - if (mod->init_size) {
83086 - ptr = module_alloc_update_bounds(mod->init_size);
83087 + if (mod->init_size_rw) {
83088 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
83089 /*
83090 * The pointer to this block is stored in the module structure
83091 * which is inside the block. This block doesn't need to be
83092 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
83093 */
83094 kmemleak_ignore(ptr);
83095 if (!ptr) {
83096 - module_free(mod, mod->module_core);
83097 + module_free(mod, mod->module_core_rw);
83098 return -ENOMEM;
83099 }
83100 - memset(ptr, 0, mod->init_size);
83101 - mod->module_init = ptr;
83102 + memset(ptr, 0, mod->init_size_rw);
83103 + mod->module_init_rw = ptr;
83104 } else
83105 - mod->module_init = NULL;
83106 + mod->module_init_rw = NULL;
83107 +
83108 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
83109 + kmemleak_not_leak(ptr);
83110 + if (!ptr) {
83111 + if (mod->module_init_rw)
83112 + module_free(mod, mod->module_init_rw);
83113 + module_free(mod, mod->module_core_rw);
83114 + return -ENOMEM;
83115 + }
83116 +
83117 + pax_open_kernel();
83118 + memset(ptr, 0, mod->core_size_rx);
83119 + pax_close_kernel();
83120 + mod->module_core_rx = ptr;
83121 +
83122 + if (mod->init_size_rx) {
83123 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
83124 + kmemleak_ignore(ptr);
83125 + if (!ptr && mod->init_size_rx) {
83126 + module_free_exec(mod, mod->module_core_rx);
83127 + if (mod->module_init_rw)
83128 + module_free(mod, mod->module_init_rw);
83129 + module_free(mod, mod->module_core_rw);
83130 + return -ENOMEM;
83131 + }
83132 +
83133 + pax_open_kernel();
83134 + memset(ptr, 0, mod->init_size_rx);
83135 + pax_close_kernel();
83136 + mod->module_init_rx = ptr;
83137 + } else
83138 + mod->module_init_rx = NULL;
83139
83140 /* Transfer each section which specifies SHF_ALLOC */
83141 pr_debug("final section addresses:\n");
83142 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
83143 if (!(shdr->sh_flags & SHF_ALLOC))
83144 continue;
83145
83146 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
83147 - dest = mod->module_init
83148 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83149 - else
83150 - dest = mod->module_core + shdr->sh_entsize;
83151 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
83152 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83153 + dest = mod->module_init_rw
83154 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83155 + else
83156 + dest = mod->module_init_rx
83157 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83158 + } else {
83159 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83160 + dest = mod->module_core_rw + shdr->sh_entsize;
83161 + else
83162 + dest = mod->module_core_rx + shdr->sh_entsize;
83163 + }
83164 +
83165 + if (shdr->sh_type != SHT_NOBITS) {
83166 +
83167 +#ifdef CONFIG_PAX_KERNEXEC
83168 +#ifdef CONFIG_X86_64
83169 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
83170 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
83171 +#endif
83172 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
83173 + pax_open_kernel();
83174 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83175 + pax_close_kernel();
83176 + } else
83177 +#endif
83178
83179 - if (shdr->sh_type != SHT_NOBITS)
83180 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83181 + }
83182 /* Update sh_addr to point to copy in image. */
83183 - shdr->sh_addr = (unsigned long)dest;
83184 +
83185 +#ifdef CONFIG_PAX_KERNEXEC
83186 + if (shdr->sh_flags & SHF_EXECINSTR)
83187 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
83188 + else
83189 +#endif
83190 +
83191 + shdr->sh_addr = (unsigned long)dest;
83192 pr_debug("\t0x%lx %s\n",
83193 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
83194 }
83195 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
83196 * Do it before processing of module parameters, so the module
83197 * can provide parameter accessor functions of its own.
83198 */
83199 - if (mod->module_init)
83200 - flush_icache_range((unsigned long)mod->module_init,
83201 - (unsigned long)mod->module_init
83202 - + mod->init_size);
83203 - flush_icache_range((unsigned long)mod->module_core,
83204 - (unsigned long)mod->module_core + mod->core_size);
83205 + if (mod->module_init_rx)
83206 + flush_icache_range((unsigned long)mod->module_init_rx,
83207 + (unsigned long)mod->module_init_rx
83208 + + mod->init_size_rx);
83209 + flush_icache_range((unsigned long)mod->module_core_rx,
83210 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
83211
83212 set_fs(old_fs);
83213 }
83214 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
83215 static void module_deallocate(struct module *mod, struct load_info *info)
83216 {
83217 percpu_modfree(mod);
83218 - module_free(mod, mod->module_init);
83219 - module_free(mod, mod->module_core);
83220 + module_free_exec(mod, mod->module_init_rx);
83221 + module_free_exec(mod, mod->module_core_rx);
83222 + module_free(mod, mod->module_init_rw);
83223 + module_free(mod, mod->module_core_rw);
83224 }
83225
83226 int __weak module_finalize(const Elf_Ehdr *hdr,
83227 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
83228 static int post_relocation(struct module *mod, const struct load_info *info)
83229 {
83230 /* Sort exception table now relocations are done. */
83231 + pax_open_kernel();
83232 sort_extable(mod->extable, mod->extable + mod->num_exentries);
83233 + pax_close_kernel();
83234
83235 /* Copy relocated percpu area over. */
83236 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
83237 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
83238 MODULE_STATE_COMING, mod);
83239
83240 /* Set RO and NX regions for core */
83241 - set_section_ro_nx(mod->module_core,
83242 - mod->core_text_size,
83243 - mod->core_ro_size,
83244 - mod->core_size);
83245 + set_section_ro_nx(mod->module_core_rx,
83246 + mod->core_size_rx,
83247 + mod->core_size_rx,
83248 + mod->core_size_rx);
83249
83250 /* Set RO and NX regions for init */
83251 - set_section_ro_nx(mod->module_init,
83252 - mod->init_text_size,
83253 - mod->init_ro_size,
83254 - mod->init_size);
83255 + set_section_ro_nx(mod->module_init_rx,
83256 + mod->init_size_rx,
83257 + mod->init_size_rx,
83258 + mod->init_size_rx);
83259
83260 do_mod_ctors(mod);
83261 /* Start the module */
83262 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
83263 mod->strtab = mod->core_strtab;
83264 #endif
83265 unset_module_init_ro_nx(mod);
83266 - module_free(mod, mod->module_init);
83267 - mod->module_init = NULL;
83268 - mod->init_size = 0;
83269 - mod->init_ro_size = 0;
83270 - mod->init_text_size = 0;
83271 + module_free(mod, mod->module_init_rw);
83272 + module_free_exec(mod, mod->module_init_rx);
83273 + mod->module_init_rw = NULL;
83274 + mod->module_init_rx = NULL;
83275 + mod->init_size_rw = 0;
83276 + mod->init_size_rx = 0;
83277 mutex_unlock(&module_mutex);
83278 wake_up_all(&module_wq);
83279
83280 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
83281 if (err)
83282 goto free_unload;
83283
83284 + /* Now copy in args */
83285 + mod->args = strndup_user(uargs, ~0UL >> 1);
83286 + if (IS_ERR(mod->args)) {
83287 + err = PTR_ERR(mod->args);
83288 + goto free_unload;
83289 + }
83290 +
83291 /* Set up MODINFO_ATTR fields */
83292 setup_modinfo(mod, info);
83293
83294 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83295 + {
83296 + char *p, *p2;
83297 +
83298 + if (strstr(mod->args, "grsec_modharden_netdev")) {
83299 + 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);
83300 + err = -EPERM;
83301 + goto free_modinfo;
83302 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
83303 + p += sizeof("grsec_modharden_normal") - 1;
83304 + p2 = strstr(p, "_");
83305 + if (p2) {
83306 + *p2 = '\0';
83307 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
83308 + *p2 = '_';
83309 + }
83310 + err = -EPERM;
83311 + goto free_modinfo;
83312 + }
83313 + }
83314 +#endif
83315 +
83316 /* Fix up syms, so that st_value is a pointer to location. */
83317 err = simplify_symbols(mod, info);
83318 if (err < 0)
83319 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
83320
83321 flush_module_icache(mod);
83322
83323 - /* Now copy in args */
83324 - mod->args = strndup_user(uargs, ~0UL >> 1);
83325 - if (IS_ERR(mod->args)) {
83326 - err = PTR_ERR(mod->args);
83327 - goto free_arch_cleanup;
83328 - }
83329 -
83330 dynamic_debug_setup(info->debug, info->num_debug);
83331
83332 /* Finally it's fully formed, ready to start executing. */
83333 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
83334 ddebug_cleanup:
83335 dynamic_debug_remove(info->debug);
83336 synchronize_sched();
83337 - kfree(mod->args);
83338 - free_arch_cleanup:
83339 module_arch_cleanup(mod);
83340 free_modinfo:
83341 free_modinfo(mod);
83342 + kfree(mod->args);
83343 free_unload:
83344 module_unload_free(mod);
83345 unlink_mod:
83346 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
83347 unsigned long nextval;
83348
83349 /* At worse, next value is at end of module */
83350 - if (within_module_init(addr, mod))
83351 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83352 + if (within_module_init_rx(addr, mod))
83353 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83354 + else if (within_module_init_rw(addr, mod))
83355 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83356 + else if (within_module_core_rx(addr, mod))
83357 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83358 + else if (within_module_core_rw(addr, mod))
83359 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83360 else
83361 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83362 + return NULL;
83363
83364 /* Scan for closest preceding symbol, and next symbol. (ELF
83365 starts real symbols at 1). */
83366 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
83367 return 0;
83368
83369 seq_printf(m, "%s %u",
83370 - mod->name, mod->init_size + mod->core_size);
83371 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83372 print_unload_info(m, mod);
83373
83374 /* Informative for users. */
83375 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
83376 mod->state == MODULE_STATE_COMING ? "Loading":
83377 "Live");
83378 /* Used by oprofile and other similar tools. */
83379 - seq_printf(m, " 0x%pK", mod->module_core);
83380 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83381
83382 /* Taints info */
83383 if (mod->taints)
83384 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
83385
83386 static int __init proc_modules_init(void)
83387 {
83388 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83389 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83390 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83391 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83392 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83393 +#else
83394 proc_create("modules", 0, NULL, &proc_modules_operations);
83395 +#endif
83396 +#else
83397 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83398 +#endif
83399 return 0;
83400 }
83401 module_init(proc_modules_init);
83402 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
83403 {
83404 struct module *mod;
83405
83406 - if (addr < module_addr_min || addr > module_addr_max)
83407 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83408 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83409 return NULL;
83410
83411 list_for_each_entry_rcu(mod, &modules, list) {
83412 if (mod->state == MODULE_STATE_UNFORMED)
83413 continue;
83414 - if (within_module_core(addr, mod)
83415 - || within_module_init(addr, mod))
83416 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83417 return mod;
83418 }
83419 return NULL;
83420 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
83421 */
83422 struct module *__module_text_address(unsigned long addr)
83423 {
83424 - struct module *mod = __module_address(addr);
83425 + struct module *mod;
83426 +
83427 +#ifdef CONFIG_X86_32
83428 + addr = ktla_ktva(addr);
83429 +#endif
83430 +
83431 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83432 + return NULL;
83433 +
83434 + mod = __module_address(addr);
83435 +
83436 if (mod) {
83437 /* Make sure it's within the text section. */
83438 - if (!within(addr, mod->module_init, mod->init_text_size)
83439 - && !within(addr, mod->module_core, mod->core_text_size))
83440 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83441 mod = NULL;
83442 }
83443 return mod;
83444 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83445 index 7e3443f..b2a1e6b 100644
83446 --- a/kernel/mutex-debug.c
83447 +++ b/kernel/mutex-debug.c
83448 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83449 }
83450
83451 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83452 - struct thread_info *ti)
83453 + struct task_struct *task)
83454 {
83455 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83456
83457 /* Mark the current thread as blocked on the lock: */
83458 - ti->task->blocked_on = waiter;
83459 + task->blocked_on = waiter;
83460 }
83461
83462 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83463 - struct thread_info *ti)
83464 + struct task_struct *task)
83465 {
83466 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83467 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83468 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83469 - ti->task->blocked_on = NULL;
83470 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83471 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83472 + task->blocked_on = NULL;
83473
83474 list_del_init(&waiter->list);
83475 waiter->task = NULL;
83476 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83477 index 0799fd3..d06ae3b 100644
83478 --- a/kernel/mutex-debug.h
83479 +++ b/kernel/mutex-debug.h
83480 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83481 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83482 extern void debug_mutex_add_waiter(struct mutex *lock,
83483 struct mutex_waiter *waiter,
83484 - struct thread_info *ti);
83485 + struct task_struct *task);
83486 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83487 - struct thread_info *ti);
83488 + struct task_struct *task);
83489 extern void debug_mutex_unlock(struct mutex *lock);
83490 extern void debug_mutex_init(struct mutex *lock, const char *name,
83491 struct lock_class_key *key);
83492 diff --git a/kernel/mutex.c b/kernel/mutex.c
83493 index ad53a66..f1bf8bc 100644
83494 --- a/kernel/mutex.c
83495 +++ b/kernel/mutex.c
83496 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83497 node->locked = 1;
83498 return;
83499 }
83500 - ACCESS_ONCE(prev->next) = node;
83501 + ACCESS_ONCE_RW(prev->next) = node;
83502 smp_wmb();
83503 /* Wait until the lock holder passes the lock down */
83504 while (!ACCESS_ONCE(node->locked))
83505 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83506 while (!(next = ACCESS_ONCE(node->next)))
83507 arch_mutex_cpu_relax();
83508 }
83509 - ACCESS_ONCE(next->locked) = 1;
83510 + ACCESS_ONCE_RW(next->locked) = 1;
83511 smp_wmb();
83512 }
83513
83514 @@ -341,7 +341,7 @@ slowpath:
83515 spin_lock_mutex(&lock->wait_lock, flags);
83516
83517 debug_mutex_lock_common(lock, &waiter);
83518 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83519 + debug_mutex_add_waiter(lock, &waiter, task);
83520
83521 /* add waiting tasks to the end of the waitqueue (FIFO): */
83522 list_add_tail(&waiter.list, &lock->wait_list);
83523 @@ -371,8 +371,7 @@ slowpath:
83524 * TASK_UNINTERRUPTIBLE case.)
83525 */
83526 if (unlikely(signal_pending_state(state, task))) {
83527 - mutex_remove_waiter(lock, &waiter,
83528 - task_thread_info(task));
83529 + mutex_remove_waiter(lock, &waiter, task);
83530 mutex_release(&lock->dep_map, 1, ip);
83531 spin_unlock_mutex(&lock->wait_lock, flags);
83532
83533 @@ -391,7 +390,7 @@ slowpath:
83534 done:
83535 lock_acquired(&lock->dep_map, ip);
83536 /* got the lock - rejoice! */
83537 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83538 + mutex_remove_waiter(lock, &waiter, task);
83539 mutex_set_owner(lock);
83540
83541 /* set it to 0 if there are no waiters left: */
83542 diff --git a/kernel/notifier.c b/kernel/notifier.c
83543 index 2d5cc4c..d9ea600 100644
83544 --- a/kernel/notifier.c
83545 +++ b/kernel/notifier.c
83546 @@ -5,6 +5,7 @@
83547 #include <linux/rcupdate.h>
83548 #include <linux/vmalloc.h>
83549 #include <linux/reboot.h>
83550 +#include <linux/mm.h>
83551
83552 /*
83553 * Notifier list for kernel code which wants to be called
83554 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83555 while ((*nl) != NULL) {
83556 if (n->priority > (*nl)->priority)
83557 break;
83558 - nl = &((*nl)->next);
83559 + nl = (struct notifier_block **)&((*nl)->next);
83560 }
83561 - n->next = *nl;
83562 + pax_open_kernel();
83563 + *(const void **)&n->next = *nl;
83564 rcu_assign_pointer(*nl, n);
83565 + pax_close_kernel();
83566 return 0;
83567 }
83568
83569 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83570 return 0;
83571 if (n->priority > (*nl)->priority)
83572 break;
83573 - nl = &((*nl)->next);
83574 + nl = (struct notifier_block **)&((*nl)->next);
83575 }
83576 - n->next = *nl;
83577 + pax_open_kernel();
83578 + *(const void **)&n->next = *nl;
83579 rcu_assign_pointer(*nl, n);
83580 + pax_close_kernel();
83581 return 0;
83582 }
83583
83584 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83585 {
83586 while ((*nl) != NULL) {
83587 if ((*nl) == n) {
83588 + pax_open_kernel();
83589 rcu_assign_pointer(*nl, n->next);
83590 + pax_close_kernel();
83591 return 0;
83592 }
83593 - nl = &((*nl)->next);
83594 + nl = (struct notifier_block **)&((*nl)->next);
83595 }
83596 return -ENOENT;
83597 }
83598 diff --git a/kernel/panic.c b/kernel/panic.c
83599 index 167ec09..0dda5f9 100644
83600 --- a/kernel/panic.c
83601 +++ b/kernel/panic.c
83602 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
83603 unsigned taint, struct slowpath_args *args)
83604 {
83605 printk(KERN_WARNING "------------[ cut here ]------------\n");
83606 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
83607 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
83608
83609 if (args)
83610 vprintk(args->fmt, args->args);
83611 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
83612 */
83613 void __stack_chk_fail(void)
83614 {
83615 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
83616 + dump_stack();
83617 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
83618 __builtin_return_address(0));
83619 }
83620 EXPORT_SYMBOL(__stack_chk_fail);
83621 diff --git a/kernel/pid.c b/kernel/pid.c
83622 index 0db3e79..95b9dc2 100644
83623 --- a/kernel/pid.c
83624 +++ b/kernel/pid.c
83625 @@ -33,6 +33,7 @@
83626 #include <linux/rculist.h>
83627 #include <linux/bootmem.h>
83628 #include <linux/hash.h>
83629 +#include <linux/security.h>
83630 #include <linux/pid_namespace.h>
83631 #include <linux/init_task.h>
83632 #include <linux/syscalls.h>
83633 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
83634
83635 int pid_max = PID_MAX_DEFAULT;
83636
83637 -#define RESERVED_PIDS 300
83638 +#define RESERVED_PIDS 500
83639
83640 int pid_max_min = RESERVED_PIDS + 1;
83641 int pid_max_max = PID_MAX_LIMIT;
83642 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
83643 */
83644 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
83645 {
83646 + struct task_struct *task;
83647 +
83648 rcu_lockdep_assert(rcu_read_lock_held(),
83649 "find_task_by_pid_ns() needs rcu_read_lock()"
83650 " protection");
83651 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83652 +
83653 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83654 +
83655 + if (gr_pid_is_chrooted(task))
83656 + return NULL;
83657 +
83658 + return task;
83659 }
83660
83661 struct task_struct *find_task_by_vpid(pid_t vnr)
83662 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
83663 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
83664 }
83665
83666 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
83667 +{
83668 + rcu_lockdep_assert(rcu_read_lock_held(),
83669 + "find_task_by_pid_ns() needs rcu_read_lock()"
83670 + " protection");
83671 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
83672 +}
83673 +
83674 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
83675 {
83676 struct pid *pid;
83677 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
83678 index 6917e8e..9909aeb 100644
83679 --- a/kernel/pid_namespace.c
83680 +++ b/kernel/pid_namespace.c
83681 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
83682 void __user *buffer, size_t *lenp, loff_t *ppos)
83683 {
83684 struct pid_namespace *pid_ns = task_active_pid_ns(current);
83685 - struct ctl_table tmp = *table;
83686 + ctl_table_no_const tmp = *table;
83687
83688 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
83689 return -EPERM;
83690 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
83691 index 42670e9..8719c2f 100644
83692 --- a/kernel/posix-cpu-timers.c
83693 +++ b/kernel/posix-cpu-timers.c
83694 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
83695
83696 static __init int init_posix_cpu_timers(void)
83697 {
83698 - struct k_clock process = {
83699 + static struct k_clock process = {
83700 .clock_getres = process_cpu_clock_getres,
83701 .clock_get = process_cpu_clock_get,
83702 .timer_create = process_cpu_timer_create,
83703 .nsleep = process_cpu_nsleep,
83704 .nsleep_restart = process_cpu_nsleep_restart,
83705 };
83706 - struct k_clock thread = {
83707 + static struct k_clock thread = {
83708 .clock_getres = thread_cpu_clock_getres,
83709 .clock_get = thread_cpu_clock_get,
83710 .timer_create = thread_cpu_timer_create,
83711 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
83712 index 424c2d4..679242f 100644
83713 --- a/kernel/posix-timers.c
83714 +++ b/kernel/posix-timers.c
83715 @@ -43,6 +43,7 @@
83716 #include <linux/hash.h>
83717 #include <linux/posix-clock.h>
83718 #include <linux/posix-timers.h>
83719 +#include <linux/grsecurity.h>
83720 #include <linux/syscalls.h>
83721 #include <linux/wait.h>
83722 #include <linux/workqueue.h>
83723 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
83724 * which we beg off on and pass to do_sys_settimeofday().
83725 */
83726
83727 -static struct k_clock posix_clocks[MAX_CLOCKS];
83728 +static struct k_clock *posix_clocks[MAX_CLOCKS];
83729
83730 /*
83731 * These ones are defined below.
83732 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
83733 */
83734 static __init int init_posix_timers(void)
83735 {
83736 - struct k_clock clock_realtime = {
83737 + static struct k_clock clock_realtime = {
83738 .clock_getres = hrtimer_get_res,
83739 .clock_get = posix_clock_realtime_get,
83740 .clock_set = posix_clock_realtime_set,
83741 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
83742 .timer_get = common_timer_get,
83743 .timer_del = common_timer_del,
83744 };
83745 - struct k_clock clock_monotonic = {
83746 + static struct k_clock clock_monotonic = {
83747 .clock_getres = hrtimer_get_res,
83748 .clock_get = posix_ktime_get_ts,
83749 .nsleep = common_nsleep,
83750 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
83751 .timer_get = common_timer_get,
83752 .timer_del = common_timer_del,
83753 };
83754 - struct k_clock clock_monotonic_raw = {
83755 + static struct k_clock clock_monotonic_raw = {
83756 .clock_getres = hrtimer_get_res,
83757 .clock_get = posix_get_monotonic_raw,
83758 };
83759 - struct k_clock clock_realtime_coarse = {
83760 + static struct k_clock clock_realtime_coarse = {
83761 .clock_getres = posix_get_coarse_res,
83762 .clock_get = posix_get_realtime_coarse,
83763 };
83764 - struct k_clock clock_monotonic_coarse = {
83765 + static struct k_clock clock_monotonic_coarse = {
83766 .clock_getres = posix_get_coarse_res,
83767 .clock_get = posix_get_monotonic_coarse,
83768 };
83769 - struct k_clock clock_tai = {
83770 + static struct k_clock clock_tai = {
83771 .clock_getres = hrtimer_get_res,
83772 .clock_get = posix_get_tai,
83773 .nsleep = common_nsleep,
83774 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
83775 .timer_get = common_timer_get,
83776 .timer_del = common_timer_del,
83777 };
83778 - struct k_clock clock_boottime = {
83779 + static struct k_clock clock_boottime = {
83780 .clock_getres = hrtimer_get_res,
83781 .clock_get = posix_get_boottime,
83782 .nsleep = common_nsleep,
83783 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
83784 return;
83785 }
83786
83787 - posix_clocks[clock_id] = *new_clock;
83788 + posix_clocks[clock_id] = new_clock;
83789 }
83790 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
83791
83792 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
83793 return (id & CLOCKFD_MASK) == CLOCKFD ?
83794 &clock_posix_dynamic : &clock_posix_cpu;
83795
83796 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
83797 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
83798 return NULL;
83799 - return &posix_clocks[id];
83800 + return posix_clocks[id];
83801 }
83802
83803 static int common_timer_create(struct k_itimer *new_timer)
83804 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
83805 struct k_clock *kc = clockid_to_kclock(which_clock);
83806 struct k_itimer *new_timer;
83807 int error, new_timer_id;
83808 - sigevent_t event;
83809 + sigevent_t event = { };
83810 int it_id_set = IT_ID_NOT_SET;
83811
83812 if (!kc)
83813 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
83814 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
83815 return -EFAULT;
83816
83817 + /* only the CLOCK_REALTIME clock can be set, all other clocks
83818 + have their clock_set fptr set to a nosettime dummy function
83819 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
83820 + call common_clock_set, which calls do_sys_settimeofday, which
83821 + we hook
83822 + */
83823 +
83824 return kc->clock_set(which_clock, &new_tp);
83825 }
83826
83827 diff --git a/kernel/power/process.c b/kernel/power/process.c
83828 index 98088e0..aaf95c0 100644
83829 --- a/kernel/power/process.c
83830 +++ b/kernel/power/process.c
83831 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
83832 u64 elapsed_csecs64;
83833 unsigned int elapsed_csecs;
83834 bool wakeup = false;
83835 + bool timedout = false;
83836
83837 do_gettimeofday(&start);
83838
83839 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
83840
83841 while (true) {
83842 todo = 0;
83843 + if (time_after(jiffies, end_time))
83844 + timedout = true;
83845 read_lock(&tasklist_lock);
83846 do_each_thread(g, p) {
83847 if (p == current || !freeze_task(p))
83848 continue;
83849
83850 - if (!freezer_should_skip(p))
83851 + if (!freezer_should_skip(p)) {
83852 todo++;
83853 + if (timedout) {
83854 + printk(KERN_ERR "Task refusing to freeze:\n");
83855 + sched_show_task(p);
83856 + }
83857 + }
83858 } while_each_thread(g, p);
83859 read_unlock(&tasklist_lock);
83860
83861 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
83862 todo += wq_busy;
83863 }
83864
83865 - if (!todo || time_after(jiffies, end_time))
83866 + if (!todo || timedout)
83867 break;
83868
83869 if (pm_wakeup_pending()) {
83870 diff --git a/kernel/printk.c b/kernel/printk.c
83871 index d37d45c..ab918b3 100644
83872 --- a/kernel/printk.c
83873 +++ b/kernel/printk.c
83874 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
83875 if (from_file && type != SYSLOG_ACTION_OPEN)
83876 return 0;
83877
83878 +#ifdef CONFIG_GRKERNSEC_DMESG
83879 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
83880 + return -EPERM;
83881 +#endif
83882 +
83883 if (syslog_action_restricted(type)) {
83884 if (capable(CAP_SYSLOG))
83885 return 0;
83886 diff --git a/kernel/profile.c b/kernel/profile.c
83887 index 0bf4007..6234708 100644
83888 --- a/kernel/profile.c
83889 +++ b/kernel/profile.c
83890 @@ -37,7 +37,7 @@ struct profile_hit {
83891 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
83892 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
83893
83894 -static atomic_t *prof_buffer;
83895 +static atomic_unchecked_t *prof_buffer;
83896 static unsigned long prof_len, prof_shift;
83897
83898 int prof_on __read_mostly;
83899 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
83900 hits[i].pc = 0;
83901 continue;
83902 }
83903 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83904 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83905 hits[i].hits = hits[i].pc = 0;
83906 }
83907 }
83908 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83909 * Add the current hit(s) and flush the write-queue out
83910 * to the global buffer:
83911 */
83912 - atomic_add(nr_hits, &prof_buffer[pc]);
83913 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
83914 for (i = 0; i < NR_PROFILE_HIT; ++i) {
83915 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83916 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83917 hits[i].pc = hits[i].hits = 0;
83918 }
83919 out:
83920 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83921 {
83922 unsigned long pc;
83923 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
83924 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83925 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83926 }
83927 #endif /* !CONFIG_SMP */
83928
83929 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
83930 return -EFAULT;
83931 buf++; p++; count--; read++;
83932 }
83933 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
83934 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
83935 if (copy_to_user(buf, (void *)pnt, count))
83936 return -EFAULT;
83937 read += count;
83938 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83939 }
83940 #endif
83941 profile_discard_flip_buffers();
83942 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83943 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83944 return count;
83945 }
83946
83947 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83948 index 335a7ae..3bbbceb 100644
83949 --- a/kernel/ptrace.c
83950 +++ b/kernel/ptrace.c
83951 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83952 if (seize)
83953 flags |= PT_SEIZED;
83954 rcu_read_lock();
83955 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83956 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83957 flags |= PT_PTRACE_CAP;
83958 rcu_read_unlock();
83959 task->ptrace = flags;
83960 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83961 break;
83962 return -EIO;
83963 }
83964 - if (copy_to_user(dst, buf, retval))
83965 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83966 return -EFAULT;
83967 copied += retval;
83968 src += retval;
83969 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
83970 bool seized = child->ptrace & PT_SEIZED;
83971 int ret = -EIO;
83972 siginfo_t siginfo, *si;
83973 - void __user *datavp = (void __user *) data;
83974 + void __user *datavp = (__force void __user *) data;
83975 unsigned long __user *datalp = datavp;
83976 unsigned long flags;
83977
83978 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83979 goto out;
83980 }
83981
83982 + if (gr_handle_ptrace(child, request)) {
83983 + ret = -EPERM;
83984 + goto out_put_task_struct;
83985 + }
83986 +
83987 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83988 ret = ptrace_attach(child, request, addr, data);
83989 /*
83990 * Some architectures need to do book-keeping after
83991 * a ptrace attach.
83992 */
83993 - if (!ret)
83994 + if (!ret) {
83995 arch_ptrace_attach(child);
83996 + gr_audit_ptrace(child);
83997 + }
83998 goto out_put_task_struct;
83999 }
84000
84001 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
84002 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
84003 if (copied != sizeof(tmp))
84004 return -EIO;
84005 - return put_user(tmp, (unsigned long __user *)data);
84006 + return put_user(tmp, (__force unsigned long __user *)data);
84007 }
84008
84009 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
84010 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
84011 }
84012
84013 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84014 - compat_long_t addr, compat_long_t data)
84015 + compat_ulong_t addr, compat_ulong_t data)
84016 {
84017 struct task_struct *child;
84018 long ret;
84019 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84020 goto out;
84021 }
84022
84023 + if (gr_handle_ptrace(child, request)) {
84024 + ret = -EPERM;
84025 + goto out_put_task_struct;
84026 + }
84027 +
84028 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84029 ret = ptrace_attach(child, request, addr, data);
84030 /*
84031 * Some architectures need to do book-keeping after
84032 * a ptrace attach.
84033 */
84034 - if (!ret)
84035 + if (!ret) {
84036 arch_ptrace_attach(child);
84037 + gr_audit_ptrace(child);
84038 + }
84039 goto out_put_task_struct;
84040 }
84041
84042 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
84043 index 48ab703..07561d4 100644
84044 --- a/kernel/rcupdate.c
84045 +++ b/kernel/rcupdate.c
84046 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
84047 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
84048 */
84049 if (till_stall_check < 3) {
84050 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
84051 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
84052 till_stall_check = 3;
84053 } else if (till_stall_check > 300) {
84054 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
84055 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
84056 till_stall_check = 300;
84057 }
84058 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
84059 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
84060 index a0714a5..2ab5e34 100644
84061 --- a/kernel/rcutiny.c
84062 +++ b/kernel/rcutiny.c
84063 @@ -46,7 +46,7 @@
84064 struct rcu_ctrlblk;
84065 static void invoke_rcu_callbacks(void);
84066 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
84067 -static void rcu_process_callbacks(struct softirq_action *unused);
84068 +static void rcu_process_callbacks(void);
84069 static void __call_rcu(struct rcu_head *head,
84070 void (*func)(struct rcu_head *rcu),
84071 struct rcu_ctrlblk *rcp);
84072 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
84073 rcu_is_callbacks_kthread()));
84074 }
84075
84076 -static void rcu_process_callbacks(struct softirq_action *unused)
84077 +static void rcu_process_callbacks(void)
84078 {
84079 __rcu_process_callbacks(&rcu_sched_ctrlblk);
84080 __rcu_process_callbacks(&rcu_bh_ctrlblk);
84081 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
84082 index 8a23300..4255818 100644
84083 --- a/kernel/rcutiny_plugin.h
84084 +++ b/kernel/rcutiny_plugin.h
84085 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
84086 have_rcu_kthread_work = morework;
84087 local_irq_restore(flags);
84088 if (work)
84089 - rcu_process_callbacks(NULL);
84090 + rcu_process_callbacks();
84091 schedule_timeout_interruptible(1); /* Leave CPU for others. */
84092 }
84093
84094 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
84095 index e1f3a8c..42c94a2 100644
84096 --- a/kernel/rcutorture.c
84097 +++ b/kernel/rcutorture.c
84098 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
84099 { 0 };
84100 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
84101 { 0 };
84102 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84103 -static atomic_t n_rcu_torture_alloc;
84104 -static atomic_t n_rcu_torture_alloc_fail;
84105 -static atomic_t n_rcu_torture_free;
84106 -static atomic_t n_rcu_torture_mberror;
84107 -static atomic_t n_rcu_torture_error;
84108 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84109 +static atomic_unchecked_t n_rcu_torture_alloc;
84110 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
84111 +static atomic_unchecked_t n_rcu_torture_free;
84112 +static atomic_unchecked_t n_rcu_torture_mberror;
84113 +static atomic_unchecked_t n_rcu_torture_error;
84114 static long n_rcu_torture_barrier_error;
84115 static long n_rcu_torture_boost_ktrerror;
84116 static long n_rcu_torture_boost_rterror;
84117 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
84118
84119 spin_lock_bh(&rcu_torture_lock);
84120 if (list_empty(&rcu_torture_freelist)) {
84121 - atomic_inc(&n_rcu_torture_alloc_fail);
84122 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
84123 spin_unlock_bh(&rcu_torture_lock);
84124 return NULL;
84125 }
84126 - atomic_inc(&n_rcu_torture_alloc);
84127 + atomic_inc_unchecked(&n_rcu_torture_alloc);
84128 p = rcu_torture_freelist.next;
84129 list_del_init(p);
84130 spin_unlock_bh(&rcu_torture_lock);
84131 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
84132 static void
84133 rcu_torture_free(struct rcu_torture *p)
84134 {
84135 - atomic_inc(&n_rcu_torture_free);
84136 + atomic_inc_unchecked(&n_rcu_torture_free);
84137 spin_lock_bh(&rcu_torture_lock);
84138 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
84139 spin_unlock_bh(&rcu_torture_lock);
84140 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
84141 i = rp->rtort_pipe_count;
84142 if (i > RCU_TORTURE_PIPE_LEN)
84143 i = RCU_TORTURE_PIPE_LEN;
84144 - atomic_inc(&rcu_torture_wcount[i]);
84145 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84146 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84147 rp->rtort_mbtest = 0;
84148 rcu_torture_free(rp);
84149 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
84150 i = rp->rtort_pipe_count;
84151 if (i > RCU_TORTURE_PIPE_LEN)
84152 i = RCU_TORTURE_PIPE_LEN;
84153 - atomic_inc(&rcu_torture_wcount[i]);
84154 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84155 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84156 rp->rtort_mbtest = 0;
84157 list_del(&rp->rtort_free);
84158 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
84159 i = old_rp->rtort_pipe_count;
84160 if (i > RCU_TORTURE_PIPE_LEN)
84161 i = RCU_TORTURE_PIPE_LEN;
84162 - atomic_inc(&rcu_torture_wcount[i]);
84163 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84164 old_rp->rtort_pipe_count++;
84165 cur_ops->deferred_free(old_rp);
84166 }
84167 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
84168 return;
84169 }
84170 if (p->rtort_mbtest == 0)
84171 - atomic_inc(&n_rcu_torture_mberror);
84172 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84173 spin_lock(&rand_lock);
84174 cur_ops->read_delay(&rand);
84175 n_rcu_torture_timers++;
84176 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
84177 continue;
84178 }
84179 if (p->rtort_mbtest == 0)
84180 - atomic_inc(&n_rcu_torture_mberror);
84181 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84182 cur_ops->read_delay(&rand);
84183 preempt_disable();
84184 pipe_count = p->rtort_pipe_count;
84185 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
84186 rcu_torture_current,
84187 rcu_torture_current_version,
84188 list_empty(&rcu_torture_freelist),
84189 - atomic_read(&n_rcu_torture_alloc),
84190 - atomic_read(&n_rcu_torture_alloc_fail),
84191 - atomic_read(&n_rcu_torture_free));
84192 + atomic_read_unchecked(&n_rcu_torture_alloc),
84193 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
84194 + atomic_read_unchecked(&n_rcu_torture_free));
84195 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
84196 - atomic_read(&n_rcu_torture_mberror),
84197 + atomic_read_unchecked(&n_rcu_torture_mberror),
84198 n_rcu_torture_boost_ktrerror,
84199 n_rcu_torture_boost_rterror);
84200 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
84201 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
84202 n_barrier_attempts,
84203 n_rcu_torture_barrier_error);
84204 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
84205 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
84206 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
84207 n_rcu_torture_barrier_error != 0 ||
84208 n_rcu_torture_boost_ktrerror != 0 ||
84209 n_rcu_torture_boost_rterror != 0 ||
84210 n_rcu_torture_boost_failure != 0 ||
84211 i > 1) {
84212 cnt += sprintf(&page[cnt], "!!! ");
84213 - atomic_inc(&n_rcu_torture_error);
84214 + atomic_inc_unchecked(&n_rcu_torture_error);
84215 WARN_ON_ONCE(1);
84216 }
84217 cnt += sprintf(&page[cnt], "Reader Pipe: ");
84218 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
84219 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
84220 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84221 cnt += sprintf(&page[cnt], " %d",
84222 - atomic_read(&rcu_torture_wcount[i]));
84223 + atomic_read_unchecked(&rcu_torture_wcount[i]));
84224 }
84225 cnt += sprintf(&page[cnt], "\n");
84226 if (cur_ops->stats)
84227 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
84228
84229 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
84230
84231 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84232 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84233 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
84234 else if (n_online_successes != n_online_attempts ||
84235 n_offline_successes != n_offline_attempts)
84236 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
84237
84238 rcu_torture_current = NULL;
84239 rcu_torture_current_version = 0;
84240 - atomic_set(&n_rcu_torture_alloc, 0);
84241 - atomic_set(&n_rcu_torture_alloc_fail, 0);
84242 - atomic_set(&n_rcu_torture_free, 0);
84243 - atomic_set(&n_rcu_torture_mberror, 0);
84244 - atomic_set(&n_rcu_torture_error, 0);
84245 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
84246 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
84247 + atomic_set_unchecked(&n_rcu_torture_free, 0);
84248 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
84249 + atomic_set_unchecked(&n_rcu_torture_error, 0);
84250 n_rcu_torture_barrier_error = 0;
84251 n_rcu_torture_boost_ktrerror = 0;
84252 n_rcu_torture_boost_rterror = 0;
84253 n_rcu_torture_boost_failure = 0;
84254 n_rcu_torture_boosts = 0;
84255 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
84256 - atomic_set(&rcu_torture_wcount[i], 0);
84257 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
84258 for_each_possible_cpu(cpu) {
84259 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84260 per_cpu(rcu_torture_count, cpu)[i] = 0;
84261 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
84262 index 3538001..e379e0b 100644
84263 --- a/kernel/rcutree.c
84264 +++ b/kernel/rcutree.c
84265 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
84266 rcu_prepare_for_idle(smp_processor_id());
84267 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84268 smp_mb__before_atomic_inc(); /* See above. */
84269 - atomic_inc(&rdtp->dynticks);
84270 + atomic_inc_unchecked(&rdtp->dynticks);
84271 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
84272 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84273 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84274
84275 /*
84276 * It is illegal to enter an extended quiescent state while
84277 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
84278 int user)
84279 {
84280 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
84281 - atomic_inc(&rdtp->dynticks);
84282 + atomic_inc_unchecked(&rdtp->dynticks);
84283 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84284 smp_mb__after_atomic_inc(); /* See above. */
84285 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84286 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84287 rcu_cleanup_after_idle(smp_processor_id());
84288 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
84289 if (!user && !is_idle_task(current)) {
84290 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
84291 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
84292
84293 if (rdtp->dynticks_nmi_nesting == 0 &&
84294 - (atomic_read(&rdtp->dynticks) & 0x1))
84295 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
84296 return;
84297 rdtp->dynticks_nmi_nesting++;
84298 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
84299 - atomic_inc(&rdtp->dynticks);
84300 + atomic_inc_unchecked(&rdtp->dynticks);
84301 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84302 smp_mb__after_atomic_inc(); /* See above. */
84303 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84304 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84305 }
84306
84307 /**
84308 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
84309 return;
84310 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84311 smp_mb__before_atomic_inc(); /* See above. */
84312 - atomic_inc(&rdtp->dynticks);
84313 + atomic_inc_unchecked(&rdtp->dynticks);
84314 smp_mb__after_atomic_inc(); /* Force delay to next write. */
84315 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84316 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84317 }
84318
84319 /**
84320 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
84321 int ret;
84322
84323 preempt_disable();
84324 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84325 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84326 preempt_enable();
84327 return ret;
84328 }
84329 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
84330 */
84331 static int dyntick_save_progress_counter(struct rcu_data *rdp)
84332 {
84333 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
84334 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84335 return (rdp->dynticks_snap & 0x1) == 0;
84336 }
84337
84338 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
84339 unsigned int curr;
84340 unsigned int snap;
84341
84342 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
84343 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84344 snap = (unsigned int)rdp->dynticks_snap;
84345
84346 /*
84347 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
84348 rdp = this_cpu_ptr(rsp->rda);
84349 rcu_preempt_check_blocked_tasks(rnp);
84350 rnp->qsmask = rnp->qsmaskinit;
84351 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84352 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84353 WARN_ON_ONCE(rnp->completed != rsp->completed);
84354 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84355 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84356 if (rnp == rdp->mynode)
84357 rcu_start_gp_per_cpu(rsp, rnp, rdp);
84358 rcu_preempt_boost_start_gp(rnp);
84359 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84360 */
84361 rcu_for_each_node_breadth_first(rsp, rnp) {
84362 raw_spin_lock_irq(&rnp->lock);
84363 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84364 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84365 rdp = this_cpu_ptr(rsp->rda);
84366 if (rnp == rdp->mynode)
84367 __rcu_process_gp_end(rsp, rnp, rdp);
84368 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84369 rsp->qlen += rdp->qlen;
84370 rdp->n_cbs_orphaned += rdp->qlen;
84371 rdp->qlen_lazy = 0;
84372 - ACCESS_ONCE(rdp->qlen) = 0;
84373 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84374 }
84375
84376 /*
84377 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84378 }
84379 smp_mb(); /* List handling before counting for rcu_barrier(). */
84380 rdp->qlen_lazy -= count_lazy;
84381 - ACCESS_ONCE(rdp->qlen) -= count;
84382 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84383 rdp->n_cbs_invoked += count;
84384
84385 /* Reinstate batch limit if we have worked down the excess. */
84386 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84387 /*
84388 * Do RCU core processing for the current CPU.
84389 */
84390 -static void rcu_process_callbacks(struct softirq_action *unused)
84391 +static void rcu_process_callbacks(void)
84392 {
84393 struct rcu_state *rsp;
84394
84395 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84396 local_irq_restore(flags);
84397 return;
84398 }
84399 - ACCESS_ONCE(rdp->qlen)++;
84400 + ACCESS_ONCE_RW(rdp->qlen)++;
84401 if (lazy)
84402 rdp->qlen_lazy++;
84403 else
84404 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
84405 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84406 * course be required on a 64-bit system.
84407 */
84408 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84409 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84410 (ulong)atomic_long_read(&rsp->expedited_done) +
84411 ULONG_MAX / 8)) {
84412 synchronize_sched();
84413 - atomic_long_inc(&rsp->expedited_wrap);
84414 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84415 return;
84416 }
84417
84418 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
84419 * Take a ticket. Note that atomic_inc_return() implies a
84420 * full memory barrier.
84421 */
84422 - snap = atomic_long_inc_return(&rsp->expedited_start);
84423 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84424 firstsnap = snap;
84425 get_online_cpus();
84426 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84427 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
84428 synchronize_sched_expedited_cpu_stop,
84429 NULL) == -EAGAIN) {
84430 put_online_cpus();
84431 - atomic_long_inc(&rsp->expedited_tryfail);
84432 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84433
84434 /* Check to see if someone else did our work for us. */
84435 s = atomic_long_read(&rsp->expedited_done);
84436 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84437 /* ensure test happens before caller kfree */
84438 smp_mb__before_atomic_inc(); /* ^^^ */
84439 - atomic_long_inc(&rsp->expedited_workdone1);
84440 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84441 return;
84442 }
84443
84444 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
84445 udelay(trycount * num_online_cpus());
84446 } else {
84447 wait_rcu_gp(call_rcu_sched);
84448 - atomic_long_inc(&rsp->expedited_normal);
84449 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84450 return;
84451 }
84452
84453 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
84454 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84455 /* ensure test happens before caller kfree */
84456 smp_mb__before_atomic_inc(); /* ^^^ */
84457 - atomic_long_inc(&rsp->expedited_workdone2);
84458 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84459 return;
84460 }
84461
84462 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
84463 * period works for us.
84464 */
84465 get_online_cpus();
84466 - snap = atomic_long_read(&rsp->expedited_start);
84467 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84468 smp_mb(); /* ensure read is before try_stop_cpus(). */
84469 }
84470 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84471 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84472
84473 /*
84474 * Everyone up to our most recent fetch is covered by our grace
84475 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
84476 * than we did already did their update.
84477 */
84478 do {
84479 - atomic_long_inc(&rsp->expedited_done_tries);
84480 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84481 s = atomic_long_read(&rsp->expedited_done);
84482 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84483 /* ensure test happens before caller kfree */
84484 smp_mb__before_atomic_inc(); /* ^^^ */
84485 - atomic_long_inc(&rsp->expedited_done_lost);
84486 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84487 break;
84488 }
84489 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84490 - atomic_long_inc(&rsp->expedited_done_exit);
84491 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84492
84493 put_online_cpus();
84494 }
84495 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84496 * ACCESS_ONCE() to prevent the compiler from speculating
84497 * the increment to precede the early-exit check.
84498 */
84499 - ACCESS_ONCE(rsp->n_barrier_done)++;
84500 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84501 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84502 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84503 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84504 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84505
84506 /* Increment ->n_barrier_done to prevent duplicate work. */
84507 smp_mb(); /* Keep increment after above mechanism. */
84508 - ACCESS_ONCE(rsp->n_barrier_done)++;
84509 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84510 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84511 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84512 smp_mb(); /* Keep increment before caller's subsequent code. */
84513 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84514 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84515 init_callback_list(rdp);
84516 rdp->qlen_lazy = 0;
84517 - ACCESS_ONCE(rdp->qlen) = 0;
84518 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84519 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84520 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84521 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84522 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84523 rdp->cpu = cpu;
84524 rdp->rsp = rsp;
84525 rcu_boot_init_nocb_percpu_data(rdp);
84526 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84527 rdp->blimit = blimit;
84528 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84529 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84530 - atomic_set(&rdp->dynticks->dynticks,
84531 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84532 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84533 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84534 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84535
84536 /* Add CPU to rcu_node bitmasks. */
84537 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
84538 struct task_struct *t;
84539
84540 for_each_rcu_flavor(rsp) {
84541 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
84542 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
84543 BUG_ON(IS_ERR(t));
84544 rnp = rcu_get_root(rsp);
84545 raw_spin_lock_irqsave(&rnp->lock, flags);
84546 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84547 index 4df5034..5ee93f2 100644
84548 --- a/kernel/rcutree.h
84549 +++ b/kernel/rcutree.h
84550 @@ -87,7 +87,7 @@ struct rcu_dynticks {
84551 long long dynticks_nesting; /* Track irq/process nesting level. */
84552 /* Process level is worth LLONG_MAX/2. */
84553 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84554 - atomic_t dynticks; /* Even value for idle, else odd. */
84555 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84556 #ifdef CONFIG_RCU_FAST_NO_HZ
84557 bool all_lazy; /* Are all CPU's CBs lazy? */
84558 unsigned long nonlazy_posted;
84559 @@ -414,17 +414,17 @@ struct rcu_state {
84560 /* _rcu_barrier(). */
84561 /* End of fields guarded by barrier_mutex. */
84562
84563 - atomic_long_t expedited_start; /* Starting ticket. */
84564 - atomic_long_t expedited_done; /* Done ticket. */
84565 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84566 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84567 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84568 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84569 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84570 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84571 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84572 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84573 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84574 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84575 + atomic_long_t expedited_done; /* Done ticket. */
84576 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84577 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84578 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84579 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84580 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84581 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84582 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84583 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84584 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84585
84586 unsigned long jiffies_force_qs; /* Time at which to invoke */
84587 /* force_quiescent_state(). */
84588 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84589 index 3db5a37..b395fb35 100644
84590 --- a/kernel/rcutree_plugin.h
84591 +++ b/kernel/rcutree_plugin.h
84592 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
84593
84594 /* Clean up and exit. */
84595 smp_mb(); /* ensure expedited GP seen before counter increment. */
84596 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
84597 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
84598 unlock_mb_ret:
84599 mutex_unlock(&sync_rcu_preempt_exp_mutex);
84600 mb_ret:
84601 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
84602 free_cpumask_var(cm);
84603 }
84604
84605 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
84606 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
84607 .store = &rcu_cpu_kthread_task,
84608 .thread_should_run = rcu_cpu_kthread_should_run,
84609 .thread_fn = rcu_cpu_kthread,
84610 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
84611 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
84612 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
84613 cpu, ticks_value, ticks_title,
84614 - atomic_read(&rdtp->dynticks) & 0xfff,
84615 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
84616 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
84617 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
84618 fast_no_hz);
84619 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
84620
84621 /* Enqueue the callback on the nocb list and update counts. */
84622 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
84623 - ACCESS_ONCE(*old_rhpp) = rhp;
84624 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
84625 atomic_long_add(rhcount, &rdp->nocb_q_count);
84626 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
84627
84628 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
84629 * Extract queued callbacks, update counts, and wait
84630 * for a grace period to elapse.
84631 */
84632 - ACCESS_ONCE(rdp->nocb_head) = NULL;
84633 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
84634 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
84635 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
84636 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
84637 - ACCESS_ONCE(rdp->nocb_p_count) += c;
84638 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
84639 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
84640 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
84641 rcu_nocb_wait_gp(rdp);
84642
84643 /* Each pass through the following loop invokes a callback. */
84644 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
84645 list = next;
84646 }
84647 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
84648 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
84649 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
84650 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
84651 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
84652 rdp->n_nocbs_invoked += c;
84653 }
84654 return 0;
84655 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
84656 t = kthread_run(rcu_nocb_kthread, rdp,
84657 "rcuo%c/%d", rsp->abbr, cpu);
84658 BUG_ON(IS_ERR(t));
84659 - ACCESS_ONCE(rdp->nocb_kthread) = t;
84660 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
84661 }
84662 }
84663
84664 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
84665 index cf6c174..a8f4b50 100644
84666 --- a/kernel/rcutree_trace.c
84667 +++ b/kernel/rcutree_trace.c
84668 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
84669 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
84670 rdp->passed_quiesce, rdp->qs_pending);
84671 seq_printf(m, " dt=%d/%llx/%d df=%lu",
84672 - atomic_read(&rdp->dynticks->dynticks),
84673 + atomic_read_unchecked(&rdp->dynticks->dynticks),
84674 rdp->dynticks->dynticks_nesting,
84675 rdp->dynticks->dynticks_nmi_nesting,
84676 rdp->dynticks_fqs);
84677 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
84678 struct rcu_state *rsp = (struct rcu_state *)m->private;
84679
84680 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",
84681 - atomic_long_read(&rsp->expedited_start),
84682 + atomic_long_read_unchecked(&rsp->expedited_start),
84683 atomic_long_read(&rsp->expedited_done),
84684 - atomic_long_read(&rsp->expedited_wrap),
84685 - atomic_long_read(&rsp->expedited_tryfail),
84686 - atomic_long_read(&rsp->expedited_workdone1),
84687 - atomic_long_read(&rsp->expedited_workdone2),
84688 - atomic_long_read(&rsp->expedited_normal),
84689 - atomic_long_read(&rsp->expedited_stoppedcpus),
84690 - atomic_long_read(&rsp->expedited_done_tries),
84691 - atomic_long_read(&rsp->expedited_done_lost),
84692 - atomic_long_read(&rsp->expedited_done_exit));
84693 + atomic_long_read_unchecked(&rsp->expedited_wrap),
84694 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
84695 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
84696 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
84697 + atomic_long_read_unchecked(&rsp->expedited_normal),
84698 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
84699 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
84700 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
84701 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
84702 return 0;
84703 }
84704
84705 diff --git a/kernel/resource.c b/kernel/resource.c
84706 index d738698..5f8e60a 100644
84707 --- a/kernel/resource.c
84708 +++ b/kernel/resource.c
84709 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
84710
84711 static int __init ioresources_init(void)
84712 {
84713 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84714 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84715 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
84716 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
84717 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84718 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
84719 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
84720 +#endif
84721 +#else
84722 proc_create("ioports", 0, NULL, &proc_ioports_operations);
84723 proc_create("iomem", 0, NULL, &proc_iomem_operations);
84724 +#endif
84725 return 0;
84726 }
84727 __initcall(ioresources_init);
84728 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
84729 index 1d96dd0..994ff19 100644
84730 --- a/kernel/rtmutex-tester.c
84731 +++ b/kernel/rtmutex-tester.c
84732 @@ -22,7 +22,7 @@
84733 #define MAX_RT_TEST_MUTEXES 8
84734
84735 static spinlock_t rttest_lock;
84736 -static atomic_t rttest_event;
84737 +static atomic_unchecked_t rttest_event;
84738
84739 struct test_thread_data {
84740 int opcode;
84741 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84742
84743 case RTTEST_LOCKCONT:
84744 td->mutexes[td->opdata] = 1;
84745 - td->event = atomic_add_return(1, &rttest_event);
84746 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84747 return 0;
84748
84749 case RTTEST_RESET:
84750 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84751 return 0;
84752
84753 case RTTEST_RESETEVENT:
84754 - atomic_set(&rttest_event, 0);
84755 + atomic_set_unchecked(&rttest_event, 0);
84756 return 0;
84757
84758 default:
84759 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84760 return ret;
84761
84762 td->mutexes[id] = 1;
84763 - td->event = atomic_add_return(1, &rttest_event);
84764 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84765 rt_mutex_lock(&mutexes[id]);
84766 - td->event = atomic_add_return(1, &rttest_event);
84767 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84768 td->mutexes[id] = 4;
84769 return 0;
84770
84771 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84772 return ret;
84773
84774 td->mutexes[id] = 1;
84775 - td->event = atomic_add_return(1, &rttest_event);
84776 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84777 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
84778 - td->event = atomic_add_return(1, &rttest_event);
84779 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84780 td->mutexes[id] = ret ? 0 : 4;
84781 return ret ? -EINTR : 0;
84782
84783 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84784 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
84785 return ret;
84786
84787 - td->event = atomic_add_return(1, &rttest_event);
84788 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84789 rt_mutex_unlock(&mutexes[id]);
84790 - td->event = atomic_add_return(1, &rttest_event);
84791 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84792 td->mutexes[id] = 0;
84793 return 0;
84794
84795 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84796 break;
84797
84798 td->mutexes[dat] = 2;
84799 - td->event = atomic_add_return(1, &rttest_event);
84800 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84801 break;
84802
84803 default:
84804 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84805 return;
84806
84807 td->mutexes[dat] = 3;
84808 - td->event = atomic_add_return(1, &rttest_event);
84809 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84810 break;
84811
84812 case RTTEST_LOCKNOWAIT:
84813 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84814 return;
84815
84816 td->mutexes[dat] = 1;
84817 - td->event = atomic_add_return(1, &rttest_event);
84818 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84819 return;
84820
84821 default:
84822 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
84823 index 64de5f8..7735e12 100644
84824 --- a/kernel/sched/auto_group.c
84825 +++ b/kernel/sched/auto_group.c
84826 @@ -11,7 +11,7 @@
84827
84828 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
84829 static struct autogroup autogroup_default;
84830 -static atomic_t autogroup_seq_nr;
84831 +static atomic_unchecked_t autogroup_seq_nr;
84832
84833 void __init autogroup_init(struct task_struct *init_task)
84834 {
84835 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
84836
84837 kref_init(&ag->kref);
84838 init_rwsem(&ag->lock);
84839 - ag->id = atomic_inc_return(&autogroup_seq_nr);
84840 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
84841 ag->tg = tg;
84842 #ifdef CONFIG_RT_GROUP_SCHED
84843 /*
84844 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
84845 index e8b3350..d83d44e 100644
84846 --- a/kernel/sched/core.c
84847 +++ b/kernel/sched/core.c
84848 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
84849 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
84850 * positive (at least 1, or number of jiffies left till timeout) if completed.
84851 */
84852 -long __sched
84853 +long __sched __intentional_overflow(-1)
84854 wait_for_completion_interruptible_timeout(struct completion *x,
84855 unsigned long timeout)
84856 {
84857 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
84858 *
84859 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
84860 */
84861 -int __sched wait_for_completion_killable(struct completion *x)
84862 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
84863 {
84864 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
84865 if (t == -ERESTARTSYS)
84866 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
84867 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
84868 * positive (at least 1, or number of jiffies left till timeout) if completed.
84869 */
84870 -long __sched
84871 +long __sched __intentional_overflow(-1)
84872 wait_for_completion_killable_timeout(struct completion *x,
84873 unsigned long timeout)
84874 {
84875 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
84876 /* convert nice value [19,-20] to rlimit style value [1,40] */
84877 int nice_rlim = 20 - nice;
84878
84879 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
84880 +
84881 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
84882 capable(CAP_SYS_NICE));
84883 }
84884 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
84885 if (nice > 19)
84886 nice = 19;
84887
84888 - if (increment < 0 && !can_nice(current, nice))
84889 + if (increment < 0 && (!can_nice(current, nice) ||
84890 + gr_handle_chroot_nice()))
84891 return -EPERM;
84892
84893 retval = security_task_setnice(current, nice);
84894 @@ -3891,6 +3894,7 @@ recheck:
84895 unsigned long rlim_rtprio =
84896 task_rlimit(p, RLIMIT_RTPRIO);
84897
84898 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
84899 /* can't set/change the rt policy */
84900 if (policy != p->policy && !rlim_rtprio)
84901 return -EPERM;
84902 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
84903
84904 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
84905
84906 -static struct ctl_table sd_ctl_dir[] = {
84907 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
84908 {
84909 .procname = "sched_domain",
84910 .mode = 0555,
84911 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
84912 {}
84913 };
84914
84915 -static struct ctl_table *sd_alloc_ctl_entry(int n)
84916 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
84917 {
84918 - struct ctl_table *entry =
84919 + ctl_table_no_const *entry =
84920 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
84921
84922 return entry;
84923 }
84924
84925 -static void sd_free_ctl_entry(struct ctl_table **tablep)
84926 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
84927 {
84928 - struct ctl_table *entry;
84929 + ctl_table_no_const *entry;
84930
84931 /*
84932 * In the intermediate directories, both the child directory and
84933 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
84934 * will always be set. In the lowest directory the names are
84935 * static strings and all have proc handlers.
84936 */
84937 - for (entry = *tablep; entry->mode; entry++) {
84938 - if (entry->child)
84939 - sd_free_ctl_entry(&entry->child);
84940 + for (entry = tablep; entry->mode; entry++) {
84941 + if (entry->child) {
84942 + sd_free_ctl_entry(entry->child);
84943 + pax_open_kernel();
84944 + entry->child = NULL;
84945 + pax_close_kernel();
84946 + }
84947 if (entry->proc_handler == NULL)
84948 kfree(entry->procname);
84949 }
84950
84951 - kfree(*tablep);
84952 - *tablep = NULL;
84953 + kfree(tablep);
84954 }
84955
84956 static int min_load_idx = 0;
84957 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84958
84959 static void
84960 -set_table_entry(struct ctl_table *entry,
84961 +set_table_entry(ctl_table_no_const *entry,
84962 const char *procname, void *data, int maxlen,
84963 umode_t mode, proc_handler *proc_handler,
84964 bool load_idx)
84965 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
84966 static struct ctl_table *
84967 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84968 {
84969 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84970 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84971
84972 if (table == NULL)
84973 return NULL;
84974 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84975 return table;
84976 }
84977
84978 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84979 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84980 {
84981 - struct ctl_table *entry, *table;
84982 + ctl_table_no_const *entry, *table;
84983 struct sched_domain *sd;
84984 int domain_num = 0, i;
84985 char buf[32];
84986 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
84987 static void register_sched_domain_sysctl(void)
84988 {
84989 int i, cpu_num = num_possible_cpus();
84990 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84991 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84992 char buf[32];
84993
84994 WARN_ON(sd_ctl_dir[0].child);
84995 + pax_open_kernel();
84996 sd_ctl_dir[0].child = entry;
84997 + pax_close_kernel();
84998
84999 if (entry == NULL)
85000 return;
85001 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
85002 if (sd_sysctl_header)
85003 unregister_sysctl_table(sd_sysctl_header);
85004 sd_sysctl_header = NULL;
85005 - if (sd_ctl_dir[0].child)
85006 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
85007 + if (sd_ctl_dir[0].child) {
85008 + sd_free_ctl_entry(sd_ctl_dir[0].child);
85009 + pax_open_kernel();
85010 + sd_ctl_dir[0].child = NULL;
85011 + pax_close_kernel();
85012 + }
85013 }
85014 #else
85015 static void register_sched_domain_sysctl(void)
85016 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
85017 * happens before everything else. This has to be lower priority than
85018 * the notifier in the perf_event subsystem, though.
85019 */
85020 -static struct notifier_block __cpuinitdata migration_notifier = {
85021 +static struct notifier_block migration_notifier = {
85022 .notifier_call = migration_call,
85023 .priority = CPU_PRI_MIGRATION,
85024 };
85025 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
85026 index 03b73be..9422b9f 100644
85027 --- a/kernel/sched/fair.c
85028 +++ b/kernel/sched/fair.c
85029 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
85030
85031 static void reset_ptenuma_scan(struct task_struct *p)
85032 {
85033 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
85034 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
85035 p->mm->numa_scan_offset = 0;
85036 }
85037
85038 @@ -5687,7 +5687,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
85039 * run_rebalance_domains is triggered when needed from the scheduler tick.
85040 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
85041 */
85042 -static void run_rebalance_domains(struct softirq_action *h)
85043 +static void run_rebalance_domains(void)
85044 {
85045 int this_cpu = smp_processor_id();
85046 struct rq *this_rq = cpu_rq(this_cpu);
85047 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
85048 index ce39224d..0e09343 100644
85049 --- a/kernel/sched/sched.h
85050 +++ b/kernel/sched/sched.h
85051 @@ -1009,7 +1009,7 @@ struct sched_class {
85052 #ifdef CONFIG_FAIR_GROUP_SCHED
85053 void (*task_move_group) (struct task_struct *p, int on_rq);
85054 #endif
85055 -};
85056 +} __do_const;
85057
85058 #define sched_class_highest (&stop_sched_class)
85059 #define for_each_class(class) \
85060 diff --git a/kernel/signal.c b/kernel/signal.c
85061 index 113411b..20d0a99 100644
85062 --- a/kernel/signal.c
85063 +++ b/kernel/signal.c
85064 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
85065
85066 int print_fatal_signals __read_mostly;
85067
85068 -static void __user *sig_handler(struct task_struct *t, int sig)
85069 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
85070 {
85071 return t->sighand->action[sig - 1].sa.sa_handler;
85072 }
85073
85074 -static int sig_handler_ignored(void __user *handler, int sig)
85075 +static int sig_handler_ignored(__sighandler_t handler, int sig)
85076 {
85077 /* Is it explicitly or implicitly ignored? */
85078 return handler == SIG_IGN ||
85079 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
85080
85081 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
85082 {
85083 - void __user *handler;
85084 + __sighandler_t handler;
85085
85086 handler = sig_handler(t, sig);
85087
85088 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
85089 atomic_inc(&user->sigpending);
85090 rcu_read_unlock();
85091
85092 + if (!override_rlimit)
85093 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
85094 +
85095 if (override_rlimit ||
85096 atomic_read(&user->sigpending) <=
85097 task_rlimit(t, RLIMIT_SIGPENDING)) {
85098 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
85099
85100 int unhandled_signal(struct task_struct *tsk, int sig)
85101 {
85102 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
85103 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
85104 if (is_global_init(tsk))
85105 return 1;
85106 if (handler != SIG_IGN && handler != SIG_DFL)
85107 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
85108 }
85109 }
85110
85111 + /* allow glibc communication via tgkill to other threads in our
85112 + thread group */
85113 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
85114 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
85115 + && gr_handle_signal(t, sig))
85116 + return -EPERM;
85117 +
85118 return security_task_kill(t, info, sig, 0);
85119 }
85120
85121 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85122 return send_signal(sig, info, p, 1);
85123 }
85124
85125 -static int
85126 +int
85127 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85128 {
85129 return send_signal(sig, info, t, 0);
85130 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85131 unsigned long int flags;
85132 int ret, blocked, ignored;
85133 struct k_sigaction *action;
85134 + int is_unhandled = 0;
85135
85136 spin_lock_irqsave(&t->sighand->siglock, flags);
85137 action = &t->sighand->action[sig-1];
85138 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85139 }
85140 if (action->sa.sa_handler == SIG_DFL)
85141 t->signal->flags &= ~SIGNAL_UNKILLABLE;
85142 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
85143 + is_unhandled = 1;
85144 ret = specific_send_sig_info(sig, info, t);
85145 spin_unlock_irqrestore(&t->sighand->siglock, flags);
85146
85147 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
85148 + normal operation */
85149 + if (is_unhandled) {
85150 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
85151 + gr_handle_crash(t, sig);
85152 + }
85153 +
85154 return ret;
85155 }
85156
85157 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85158 ret = check_kill_permission(sig, info, p);
85159 rcu_read_unlock();
85160
85161 - if (!ret && sig)
85162 + if (!ret && sig) {
85163 ret = do_send_sig_info(sig, info, p, true);
85164 + if (!ret)
85165 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
85166 + }
85167
85168 return ret;
85169 }
85170 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
85171 int error = -ESRCH;
85172
85173 rcu_read_lock();
85174 - p = find_task_by_vpid(pid);
85175 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
85176 + /* allow glibc communication via tgkill to other threads in our
85177 + thread group */
85178 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
85179 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
85180 + p = find_task_by_vpid_unrestricted(pid);
85181 + else
85182 +#endif
85183 + p = find_task_by_vpid(pid);
85184 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
85185 error = check_kill_permission(sig, info, p);
85186 /*
85187 @@ -3219,6 +3250,16 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
85188 __put_user(t->sas_ss_size, &uss->ss_size);
85189 }
85190
85191 +#ifdef CONFIG_X86
85192 +void __save_altstack_ex(stack_t __user *uss, unsigned long sp)
85193 +{
85194 + struct task_struct *t = current;
85195 + put_user_ex((void __user *)t->sas_ss_sp, &uss->ss_sp);
85196 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
85197 + put_user_ex(t->sas_ss_size, &uss->ss_size);
85198 +}
85199 +#endif
85200 +
85201 #ifdef CONFIG_COMPAT
85202 COMPAT_SYSCALL_DEFINE2(sigaltstack,
85203 const compat_stack_t __user *, uss_ptr,
85204 @@ -3240,8 +3281,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
85205 }
85206 seg = get_fs();
85207 set_fs(KERNEL_DS);
85208 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
85209 - (stack_t __force __user *) &uoss,
85210 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
85211 + (stack_t __force_user *) &uoss,
85212 compat_user_stack_pointer());
85213 set_fs(seg);
85214 if (ret >= 0 && uoss_ptr) {
85215 @@ -3268,6 +3309,16 @@ int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
85216 __put_user(sas_ss_flags(sp), &uss->ss_flags) |
85217 __put_user(t->sas_ss_size, &uss->ss_size);
85218 }
85219 +
85220 +#ifdef CONFIG_X86
85221 +void __compat_save_altstack_ex(compat_stack_t __user *uss, unsigned long sp)
85222 +{
85223 + struct task_struct *t = current;
85224 + put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &uss->ss_sp);
85225 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
85226 + put_user_ex(t->sas_ss_size, &uss->ss_size);
85227 +}
85228 +#endif
85229 #endif
85230
85231 #ifdef __ARCH_WANT_SYS_SIGPENDING
85232 diff --git a/kernel/smp.c b/kernel/smp.c
85233 index 4dba0f7..fe9f773 100644
85234 --- a/kernel/smp.c
85235 +++ b/kernel/smp.c
85236 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
85237 return NOTIFY_OK;
85238 }
85239
85240 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
85241 +static struct notifier_block hotplug_cfd_notifier = {
85242 .notifier_call = hotplug_cfd,
85243 };
85244
85245 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
85246 index 02fc5c9..e54c335 100644
85247 --- a/kernel/smpboot.c
85248 +++ b/kernel/smpboot.c
85249 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
85250 }
85251 smpboot_unpark_thread(plug_thread, cpu);
85252 }
85253 - list_add(&plug_thread->list, &hotplug_threads);
85254 + pax_list_add(&plug_thread->list, &hotplug_threads);
85255 out:
85256 mutex_unlock(&smpboot_threads_lock);
85257 return ret;
85258 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
85259 {
85260 get_online_cpus();
85261 mutex_lock(&smpboot_threads_lock);
85262 - list_del(&plug_thread->list);
85263 + pax_list_del(&plug_thread->list);
85264 smpboot_destroy_threads(plug_thread);
85265 mutex_unlock(&smpboot_threads_lock);
85266 put_online_cpus();
85267 diff --git a/kernel/softirq.c b/kernel/softirq.c
85268 index 3d6833f..da6d93d 100644
85269 --- a/kernel/softirq.c
85270 +++ b/kernel/softirq.c
85271 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
85272 EXPORT_SYMBOL(irq_stat);
85273 #endif
85274
85275 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
85276 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
85277
85278 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
85279
85280 -char *softirq_to_name[NR_SOFTIRQS] = {
85281 +const char * const softirq_to_name[NR_SOFTIRQS] = {
85282 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
85283 "TASKLET", "SCHED", "HRTIMER", "RCU"
85284 };
85285 @@ -250,7 +250,7 @@ restart:
85286 kstat_incr_softirqs_this_cpu(vec_nr);
85287
85288 trace_softirq_entry(vec_nr);
85289 - h->action(h);
85290 + h->action();
85291 trace_softirq_exit(vec_nr);
85292 if (unlikely(prev_count != preempt_count())) {
85293 printk(KERN_ERR "huh, entered softirq %u %s %p"
85294 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
85295 or_softirq_pending(1UL << nr);
85296 }
85297
85298 -void open_softirq(int nr, void (*action)(struct softirq_action *))
85299 +void __init open_softirq(int nr, void (*action)(void))
85300 {
85301 softirq_vec[nr].action = action;
85302 }
85303 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
85304
85305 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
85306
85307 -static void tasklet_action(struct softirq_action *a)
85308 +static void tasklet_action(void)
85309 {
85310 struct tasklet_struct *list;
85311
85312 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
85313 }
85314 }
85315
85316 -static void tasklet_hi_action(struct softirq_action *a)
85317 +static void tasklet_hi_action(void)
85318 {
85319 struct tasklet_struct *list;
85320
85321 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
85322 return NOTIFY_OK;
85323 }
85324
85325 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
85326 +static struct notifier_block remote_softirq_cpu_notifier = {
85327 .notifier_call = remote_softirq_cpu_notify,
85328 };
85329
85330 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
85331 return NOTIFY_OK;
85332 }
85333
85334 -static struct notifier_block __cpuinitdata cpu_nfb = {
85335 +static struct notifier_block cpu_nfb = {
85336 .notifier_call = cpu_callback
85337 };
85338
85339 -static struct smp_hotplug_thread softirq_threads = {
85340 +static struct smp_hotplug_thread softirq_threads __read_only = {
85341 .store = &ksoftirqd,
85342 .thread_should_run = ksoftirqd_should_run,
85343 .thread_fn = run_ksoftirqd,
85344 diff --git a/kernel/srcu.c b/kernel/srcu.c
85345 index 01d5ccb..cdcbee6 100644
85346 --- a/kernel/srcu.c
85347 +++ b/kernel/srcu.c
85348 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
85349
85350 idx = ACCESS_ONCE(sp->completed) & 0x1;
85351 preempt_disable();
85352 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85353 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85354 smp_mb(); /* B */ /* Avoid leaking the critical section. */
85355 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85356 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85357 preempt_enable();
85358 return idx;
85359 }
85360 diff --git a/kernel/sys.c b/kernel/sys.c
85361 index 2bbd9a7..0875671 100644
85362 --- a/kernel/sys.c
85363 +++ b/kernel/sys.c
85364 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
85365 error = -EACCES;
85366 goto out;
85367 }
85368 +
85369 + if (gr_handle_chroot_setpriority(p, niceval)) {
85370 + error = -EACCES;
85371 + goto out;
85372 + }
85373 +
85374 no_nice = security_task_setnice(p, niceval);
85375 if (no_nice) {
85376 error = no_nice;
85377 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
85378 goto error;
85379 }
85380
85381 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85382 + goto error;
85383 +
85384 if (rgid != (gid_t) -1 ||
85385 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85386 new->sgid = new->egid;
85387 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85388 old = current_cred();
85389
85390 retval = -EPERM;
85391 +
85392 + if (gr_check_group_change(kgid, kgid, kgid))
85393 + goto error;
85394 +
85395 if (nsown_capable(CAP_SETGID))
85396 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85397 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85398 @@ -678,7 +691,7 @@ error:
85399 /*
85400 * change the user struct in a credentials set to match the new UID
85401 */
85402 -static int set_user(struct cred *new)
85403 +int set_user(struct cred *new)
85404 {
85405 struct user_struct *new_user;
85406
85407 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85408 goto error;
85409 }
85410
85411 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85412 + goto error;
85413 +
85414 if (!uid_eq(new->uid, old->uid)) {
85415 retval = set_user(new);
85416 if (retval < 0)
85417 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85418 old = current_cred();
85419
85420 retval = -EPERM;
85421 +
85422 + if (gr_check_crash_uid(kuid))
85423 + goto error;
85424 + if (gr_check_user_change(kuid, kuid, kuid))
85425 + goto error;
85426 +
85427 if (nsown_capable(CAP_SETUID)) {
85428 new->suid = new->uid = kuid;
85429 if (!uid_eq(kuid, old->uid)) {
85430 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85431 goto error;
85432 }
85433
85434 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85435 + goto error;
85436 +
85437 if (ruid != (uid_t) -1) {
85438 new->uid = kruid;
85439 if (!uid_eq(kruid, old->uid)) {
85440 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85441 goto error;
85442 }
85443
85444 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85445 + goto error;
85446 +
85447 if (rgid != (gid_t) -1)
85448 new->gid = krgid;
85449 if (egid != (gid_t) -1)
85450 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85451 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85452 nsown_capable(CAP_SETUID)) {
85453 if (!uid_eq(kuid, old->fsuid)) {
85454 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85455 + goto error;
85456 +
85457 new->fsuid = kuid;
85458 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85459 goto change_okay;
85460 }
85461 }
85462
85463 +error:
85464 abort_creds(new);
85465 return old_fsuid;
85466
85467 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85468 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85469 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85470 nsown_capable(CAP_SETGID)) {
85471 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85472 + goto error;
85473 +
85474 if (!gid_eq(kgid, old->fsgid)) {
85475 new->fsgid = kgid;
85476 goto change_okay;
85477 }
85478 }
85479
85480 +error:
85481 abort_creds(new);
85482 return old_fsgid;
85483
85484 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85485 return -EFAULT;
85486
85487 down_read(&uts_sem);
85488 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85489 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85490 __OLD_UTS_LEN);
85491 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85492 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85493 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85494 __OLD_UTS_LEN);
85495 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85496 - error |= __copy_to_user(&name->release, &utsname()->release,
85497 + error |= __copy_to_user(name->release, &utsname()->release,
85498 __OLD_UTS_LEN);
85499 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85500 - error |= __copy_to_user(&name->version, &utsname()->version,
85501 + error |= __copy_to_user(name->version, &utsname()->version,
85502 __OLD_UTS_LEN);
85503 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85504 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85505 + error |= __copy_to_user(name->machine, &utsname()->machine,
85506 __OLD_UTS_LEN);
85507 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85508 up_read(&uts_sem);
85509 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85510 */
85511 new_rlim->rlim_cur = 1;
85512 }
85513 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85514 + is changed to a lower value. Since tasks can be created by the same
85515 + user in between this limit change and an execve by this task, force
85516 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85517 + */
85518 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85519 + tsk->flags |= PF_NPROC_EXCEEDED;
85520 }
85521 if (!retval) {
85522 if (old_rlim)
85523 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85524 index 9edcf45..713c960 100644
85525 --- a/kernel/sysctl.c
85526 +++ b/kernel/sysctl.c
85527 @@ -93,7 +93,6 @@
85528
85529
85530 #if defined(CONFIG_SYSCTL)
85531 -
85532 /* External variables not in a header file. */
85533 extern int sysctl_overcommit_memory;
85534 extern int sysctl_overcommit_ratio;
85535 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
85536
85537 /* Constants used for minimum and maximum */
85538 #ifdef CONFIG_LOCKUP_DETECTOR
85539 -static int sixty = 60;
85540 -static int neg_one = -1;
85541 +static int sixty __read_only = 60;
85542 #endif
85543
85544 -static int zero;
85545 -static int __maybe_unused one = 1;
85546 -static int __maybe_unused two = 2;
85547 -static int __maybe_unused three = 3;
85548 -static unsigned long one_ul = 1;
85549 -static int one_hundred = 100;
85550 +static int neg_one __read_only = -1;
85551 +static int zero __read_only = 0;
85552 +static int __maybe_unused one __read_only = 1;
85553 +static int __maybe_unused two __read_only = 2;
85554 +static int __maybe_unused three __read_only = 3;
85555 +static unsigned long one_ul __read_only = 1;
85556 +static int one_hundred __read_only = 100;
85557 #ifdef CONFIG_PRINTK
85558 -static int ten_thousand = 10000;
85559 +static int ten_thousand __read_only = 10000;
85560 #endif
85561
85562 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85563 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85564 void __user *buffer, size_t *lenp, loff_t *ppos);
85565 #endif
85566
85567 -#ifdef CONFIG_PRINTK
85568 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85569 void __user *buffer, size_t *lenp, loff_t *ppos);
85570 -#endif
85571
85572 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85573 void __user *buffer, size_t *lenp, loff_t *ppos);
85574 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85575
85576 #endif
85577
85578 +extern struct ctl_table grsecurity_table[];
85579 +
85580 static struct ctl_table kern_table[];
85581 static struct ctl_table vm_table[];
85582 static struct ctl_table fs_table[];
85583 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
85584 int sysctl_legacy_va_layout;
85585 #endif
85586
85587 +#ifdef CONFIG_PAX_SOFTMODE
85588 +static ctl_table pax_table[] = {
85589 + {
85590 + .procname = "softmode",
85591 + .data = &pax_softmode,
85592 + .maxlen = sizeof(unsigned int),
85593 + .mode = 0600,
85594 + .proc_handler = &proc_dointvec,
85595 + },
85596 +
85597 + { }
85598 +};
85599 +#endif
85600 +
85601 /* The default sysctl tables: */
85602
85603 static struct ctl_table sysctl_base_table[] = {
85604 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
85605 #endif
85606
85607 static struct ctl_table kern_table[] = {
85608 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
85609 + {
85610 + .procname = "grsecurity",
85611 + .mode = 0500,
85612 + .child = grsecurity_table,
85613 + },
85614 +#endif
85615 +
85616 +#ifdef CONFIG_PAX_SOFTMODE
85617 + {
85618 + .procname = "pax",
85619 + .mode = 0500,
85620 + .child = pax_table,
85621 + },
85622 +#endif
85623 +
85624 {
85625 .procname = "sched_child_runs_first",
85626 .data = &sysctl_sched_child_runs_first,
85627 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
85628 .data = &modprobe_path,
85629 .maxlen = KMOD_PATH_LEN,
85630 .mode = 0644,
85631 - .proc_handler = proc_dostring,
85632 + .proc_handler = proc_dostring_modpriv,
85633 },
85634 {
85635 .procname = "modules_disabled",
85636 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
85637 .extra1 = &zero,
85638 .extra2 = &one,
85639 },
85640 +#endif
85641 {
85642 .procname = "kptr_restrict",
85643 .data = &kptr_restrict,
85644 .maxlen = sizeof(int),
85645 .mode = 0644,
85646 .proc_handler = proc_dointvec_minmax_sysadmin,
85647 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85648 + .extra1 = &two,
85649 +#else
85650 .extra1 = &zero,
85651 +#endif
85652 .extra2 = &two,
85653 },
85654 -#endif
85655 {
85656 .procname = "ngroups_max",
85657 .data = &ngroups_max,
85658 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
85659 */
85660 {
85661 .procname = "perf_event_paranoid",
85662 - .data = &sysctl_perf_event_paranoid,
85663 - .maxlen = sizeof(sysctl_perf_event_paranoid),
85664 + .data = &sysctl_perf_event_legitimately_concerned,
85665 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
85666 .mode = 0644,
85667 - .proc_handler = proc_dointvec,
85668 + /* go ahead, be a hero */
85669 + .proc_handler = proc_dointvec_minmax_sysadmin,
85670 + .extra1 = &neg_one,
85671 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85672 + .extra2 = &three,
85673 +#else
85674 + .extra2 = &two,
85675 +#endif
85676 },
85677 {
85678 .procname = "perf_event_mlock_kb",
85679 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
85680 .proc_handler = proc_dointvec_minmax,
85681 .extra1 = &zero,
85682 },
85683 + {
85684 + .procname = "heap_stack_gap",
85685 + .data = &sysctl_heap_stack_gap,
85686 + .maxlen = sizeof(sysctl_heap_stack_gap),
85687 + .mode = 0644,
85688 + .proc_handler = proc_doulongvec_minmax,
85689 + },
85690 #else
85691 {
85692 .procname = "nr_trim_pages",
85693 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
85694 buffer, lenp, ppos);
85695 }
85696
85697 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85698 + void __user *buffer, size_t *lenp, loff_t *ppos)
85699 +{
85700 + if (write && !capable(CAP_SYS_MODULE))
85701 + return -EPERM;
85702 +
85703 + return _proc_do_string(table->data, table->maxlen, write,
85704 + buffer, lenp, ppos);
85705 +}
85706 +
85707 static size_t proc_skip_spaces(char **buf)
85708 {
85709 size_t ret;
85710 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
85711 len = strlen(tmp);
85712 if (len > *size)
85713 len = *size;
85714 + if (len > sizeof(tmp))
85715 + len = sizeof(tmp);
85716 if (copy_to_user(*buf, tmp, len))
85717 return -EFAULT;
85718 *size -= len;
85719 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
85720 static int proc_taint(struct ctl_table *table, int write,
85721 void __user *buffer, size_t *lenp, loff_t *ppos)
85722 {
85723 - struct ctl_table t;
85724 + ctl_table_no_const t;
85725 unsigned long tmptaint = get_taint();
85726 int err;
85727
85728 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
85729 return err;
85730 }
85731
85732 -#ifdef CONFIG_PRINTK
85733 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85734 void __user *buffer, size_t *lenp, loff_t *ppos)
85735 {
85736 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85737
85738 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
85739 }
85740 -#endif
85741
85742 struct do_proc_dointvec_minmax_conv_param {
85743 int *min;
85744 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
85745 *i = val;
85746 } else {
85747 val = convdiv * (*i) / convmul;
85748 - if (!first)
85749 + if (!first) {
85750 err = proc_put_char(&buffer, &left, '\t');
85751 + if (err)
85752 + break;
85753 + }
85754 err = proc_put_long(&buffer, &left, val, false);
85755 if (err)
85756 break;
85757 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
85758 return -ENOSYS;
85759 }
85760
85761 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85762 + void __user *buffer, size_t *lenp, loff_t *ppos)
85763 +{
85764 + return -ENOSYS;
85765 +}
85766 +
85767 int proc_dointvec(struct ctl_table *table, int write,
85768 void __user *buffer, size_t *lenp, loff_t *ppos)
85769 {
85770 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
85771 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
85772 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
85773 EXPORT_SYMBOL(proc_dostring);
85774 +EXPORT_SYMBOL(proc_dostring_modpriv);
85775 EXPORT_SYMBOL(proc_doulongvec_minmax);
85776 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
85777 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
85778 index 145bb4d..b2aa969 100644
85779 --- a/kernel/taskstats.c
85780 +++ b/kernel/taskstats.c
85781 @@ -28,9 +28,12 @@
85782 #include <linux/fs.h>
85783 #include <linux/file.h>
85784 #include <linux/pid_namespace.h>
85785 +#include <linux/grsecurity.h>
85786 #include <net/genetlink.h>
85787 #include <linux/atomic.h>
85788
85789 +extern int gr_is_taskstats_denied(int pid);
85790 +
85791 /*
85792 * Maximum length of a cpumask that can be specified in
85793 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
85794 @@ -570,6 +573,9 @@ err:
85795
85796 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
85797 {
85798 + if (gr_is_taskstats_denied(current->pid))
85799 + return -EACCES;
85800 +
85801 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
85802 return cmd_attr_register_cpumask(info);
85803 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
85804 diff --git a/kernel/time.c b/kernel/time.c
85805 index d3617db..c98bbe9 100644
85806 --- a/kernel/time.c
85807 +++ b/kernel/time.c
85808 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
85809 return error;
85810
85811 if (tz) {
85812 + /* we log in do_settimeofday called below, so don't log twice
85813 + */
85814 + if (!tv)
85815 + gr_log_timechange();
85816 +
85817 sys_tz = *tz;
85818 update_vsyscall_tz();
85819 if (firsttime) {
85820 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
85821 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
85822 * value to a scaled second value.
85823 */
85824 -unsigned long
85825 +unsigned long __intentional_overflow(-1)
85826 timespec_to_jiffies(const struct timespec *value)
85827 {
85828 unsigned long sec = value->tv_sec;
85829 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
85830 index f11d83b..d016d91 100644
85831 --- a/kernel/time/alarmtimer.c
85832 +++ b/kernel/time/alarmtimer.c
85833 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
85834 struct platform_device *pdev;
85835 int error = 0;
85836 int i;
85837 - struct k_clock alarm_clock = {
85838 + static struct k_clock alarm_clock = {
85839 .clock_getres = alarm_clock_getres,
85840 .clock_get = alarm_clock_get,
85841 .timer_create = alarm_timer_create,
85842 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
85843 index baeeb5c..c22704a 100644
85844 --- a/kernel/time/timekeeping.c
85845 +++ b/kernel/time/timekeeping.c
85846 @@ -15,6 +15,7 @@
85847 #include <linux/init.h>
85848 #include <linux/mm.h>
85849 #include <linux/sched.h>
85850 +#include <linux/grsecurity.h>
85851 #include <linux/syscore_ops.h>
85852 #include <linux/clocksource.h>
85853 #include <linux/jiffies.h>
85854 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
85855 if (!timespec_valid_strict(tv))
85856 return -EINVAL;
85857
85858 + gr_log_timechange();
85859 +
85860 raw_spin_lock_irqsave(&timekeeper_lock, flags);
85861 write_seqcount_begin(&timekeeper_seq);
85862
85863 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
85864 index 3bdf283..cc68d83 100644
85865 --- a/kernel/time/timer_list.c
85866 +++ b/kernel/time/timer_list.c
85867 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
85868
85869 static void print_name_offset(struct seq_file *m, void *sym)
85870 {
85871 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85872 + SEQ_printf(m, "<%p>", NULL);
85873 +#else
85874 char symname[KSYM_NAME_LEN];
85875
85876 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
85877 SEQ_printf(m, "<%pK>", sym);
85878 else
85879 SEQ_printf(m, "%s", symname);
85880 +#endif
85881 }
85882
85883 static void
85884 @@ -119,7 +123,11 @@ next_one:
85885 static void
85886 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
85887 {
85888 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85889 + SEQ_printf(m, " .base: %p\n", NULL);
85890 +#else
85891 SEQ_printf(m, " .base: %pK\n", base);
85892 +#endif
85893 SEQ_printf(m, " .index: %d\n",
85894 base->index);
85895 SEQ_printf(m, " .resolution: %Lu nsecs\n",
85896 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
85897 {
85898 struct proc_dir_entry *pe;
85899
85900 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85901 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
85902 +#else
85903 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
85904 +#endif
85905 if (!pe)
85906 return -ENOMEM;
85907 return 0;
85908 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
85909 index 0b537f2..40d6c20 100644
85910 --- a/kernel/time/timer_stats.c
85911 +++ b/kernel/time/timer_stats.c
85912 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
85913 static unsigned long nr_entries;
85914 static struct entry entries[MAX_ENTRIES];
85915
85916 -static atomic_t overflow_count;
85917 +static atomic_unchecked_t overflow_count;
85918
85919 /*
85920 * The entries are in a hash-table, for fast lookup:
85921 @@ -140,7 +140,7 @@ static void reset_entries(void)
85922 nr_entries = 0;
85923 memset(entries, 0, sizeof(entries));
85924 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
85925 - atomic_set(&overflow_count, 0);
85926 + atomic_set_unchecked(&overflow_count, 0);
85927 }
85928
85929 static struct entry *alloc_entry(void)
85930 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85931 if (likely(entry))
85932 entry->count++;
85933 else
85934 - atomic_inc(&overflow_count);
85935 + atomic_inc_unchecked(&overflow_count);
85936
85937 out_unlock:
85938 raw_spin_unlock_irqrestore(lock, flags);
85939 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85940
85941 static void print_name_offset(struct seq_file *m, unsigned long addr)
85942 {
85943 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85944 + seq_printf(m, "<%p>", NULL);
85945 +#else
85946 char symname[KSYM_NAME_LEN];
85947
85948 if (lookup_symbol_name(addr, symname) < 0)
85949 - seq_printf(m, "<%p>", (void *)addr);
85950 + seq_printf(m, "<%pK>", (void *)addr);
85951 else
85952 seq_printf(m, "%s", symname);
85953 +#endif
85954 }
85955
85956 static int tstats_show(struct seq_file *m, void *v)
85957 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
85958
85959 seq_puts(m, "Timer Stats Version: v0.2\n");
85960 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
85961 - if (atomic_read(&overflow_count))
85962 + if (atomic_read_unchecked(&overflow_count))
85963 seq_printf(m, "Overflow: %d entries\n",
85964 - atomic_read(&overflow_count));
85965 + atomic_read_unchecked(&overflow_count));
85966
85967 for (i = 0; i < nr_entries; i++) {
85968 entry = entries + i;
85969 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
85970 {
85971 struct proc_dir_entry *pe;
85972
85973 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85974 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
85975 +#else
85976 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
85977 +#endif
85978 if (!pe)
85979 return -ENOMEM;
85980 return 0;
85981 diff --git a/kernel/timer.c b/kernel/timer.c
85982 index 15bc1b4..32da49c 100644
85983 --- a/kernel/timer.c
85984 +++ b/kernel/timer.c
85985 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
85986 /*
85987 * This function runs timers and the timer-tq in bottom half context.
85988 */
85989 -static void run_timer_softirq(struct softirq_action *h)
85990 +static void run_timer_softirq(void)
85991 {
85992 struct tvec_base *base = __this_cpu_read(tvec_bases);
85993
85994 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
85995 *
85996 * In all cases the return value is guaranteed to be non-negative.
85997 */
85998 -signed long __sched schedule_timeout(signed long timeout)
85999 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
86000 {
86001 struct timer_list timer;
86002 unsigned long expire;
86003 @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
86004 return NOTIFY_OK;
86005 }
86006
86007 -static struct notifier_block __cpuinitdata timers_nb = {
86008 +static struct notifier_block timers_nb = {
86009 .notifier_call = timer_cpu_notify,
86010 };
86011
86012 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
86013 index b8b8560..75b1a09 100644
86014 --- a/kernel/trace/blktrace.c
86015 +++ b/kernel/trace/blktrace.c
86016 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
86017 struct blk_trace *bt = filp->private_data;
86018 char buf[16];
86019
86020 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
86021 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
86022
86023 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
86024 }
86025 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
86026 return 1;
86027
86028 bt = buf->chan->private_data;
86029 - atomic_inc(&bt->dropped);
86030 + atomic_inc_unchecked(&bt->dropped);
86031 return 0;
86032 }
86033
86034 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
86035
86036 bt->dir = dir;
86037 bt->dev = dev;
86038 - atomic_set(&bt->dropped, 0);
86039 + atomic_set_unchecked(&bt->dropped, 0);
86040
86041 ret = -EIO;
86042 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
86043 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
86044 index f23449d..b8cc3a1 100644
86045 --- a/kernel/trace/ftrace.c
86046 +++ b/kernel/trace/ftrace.c
86047 @@ -1925,12 +1925,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
86048 if (unlikely(ftrace_disabled))
86049 return 0;
86050
86051 + ret = ftrace_arch_code_modify_prepare();
86052 + FTRACE_WARN_ON(ret);
86053 + if (ret)
86054 + return 0;
86055 +
86056 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
86057 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
86058 if (ret) {
86059 ftrace_bug(ret, ip);
86060 - return 0;
86061 }
86062 - return 1;
86063 + return ret ? 0 : 1;
86064 }
86065
86066 /*
86067 @@ -3994,8 +3999,10 @@ static int ftrace_process_locs(struct module *mod,
86068 if (!count)
86069 return 0;
86070
86071 + pax_open_kernel();
86072 sort(start, count, sizeof(*start),
86073 ftrace_cmp_ips, ftrace_swap_ips);
86074 + pax_close_kernel();
86075
86076 start_pg = ftrace_allocate_pages(count);
86077 if (!start_pg)
86078 @@ -4718,8 +4725,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
86079 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
86080
86081 static int ftrace_graph_active;
86082 -static struct notifier_block ftrace_suspend_notifier;
86083 -
86084 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
86085 {
86086 return 0;
86087 @@ -4863,6 +4868,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
86088 return NOTIFY_DONE;
86089 }
86090
86091 +static struct notifier_block ftrace_suspend_notifier = {
86092 + .notifier_call = ftrace_suspend_notifier_call
86093 +};
86094 +
86095 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86096 trace_func_graph_ent_t entryfunc)
86097 {
86098 @@ -4876,7 +4885,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86099 goto out;
86100 }
86101
86102 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
86103 register_pm_notifier(&ftrace_suspend_notifier);
86104
86105 ftrace_graph_active++;
86106 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
86107 index e444ff8..438b8f4 100644
86108 --- a/kernel/trace/ring_buffer.c
86109 +++ b/kernel/trace/ring_buffer.c
86110 @@ -352,9 +352,9 @@ struct buffer_data_page {
86111 */
86112 struct buffer_page {
86113 struct list_head list; /* list of buffer pages */
86114 - local_t write; /* index for next write */
86115 + local_unchecked_t write; /* index for next write */
86116 unsigned read; /* index for next read */
86117 - local_t entries; /* entries on this page */
86118 + local_unchecked_t entries; /* entries on this page */
86119 unsigned long real_end; /* real end of data */
86120 struct buffer_data_page *page; /* Actual data page */
86121 };
86122 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
86123 unsigned long last_overrun;
86124 local_t entries_bytes;
86125 local_t entries;
86126 - local_t overrun;
86127 - local_t commit_overrun;
86128 + local_unchecked_t overrun;
86129 + local_unchecked_t commit_overrun;
86130 local_t dropped_events;
86131 local_t committing;
86132 local_t commits;
86133 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86134 *
86135 * We add a counter to the write field to denote this.
86136 */
86137 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
86138 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
86139 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
86140 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
86141
86142 /*
86143 * Just make sure we have seen our old_write and synchronize
86144 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86145 * cmpxchg to only update if an interrupt did not already
86146 * do it for us. If the cmpxchg fails, we don't care.
86147 */
86148 - (void)local_cmpxchg(&next_page->write, old_write, val);
86149 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
86150 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
86151 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
86152
86153 /*
86154 * No need to worry about races with clearing out the commit.
86155 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
86156
86157 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
86158 {
86159 - return local_read(&bpage->entries) & RB_WRITE_MASK;
86160 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
86161 }
86162
86163 static inline unsigned long rb_page_write(struct buffer_page *bpage)
86164 {
86165 - return local_read(&bpage->write) & RB_WRITE_MASK;
86166 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
86167 }
86168
86169 static int
86170 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
86171 * bytes consumed in ring buffer from here.
86172 * Increment overrun to account for the lost events.
86173 */
86174 - local_add(page_entries, &cpu_buffer->overrun);
86175 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
86176 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86177 }
86178
86179 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
86180 * it is our responsibility to update
86181 * the counters.
86182 */
86183 - local_add(entries, &cpu_buffer->overrun);
86184 + local_add_unchecked(entries, &cpu_buffer->overrun);
86185 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86186
86187 /*
86188 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86189 if (tail == BUF_PAGE_SIZE)
86190 tail_page->real_end = 0;
86191
86192 - local_sub(length, &tail_page->write);
86193 + local_sub_unchecked(length, &tail_page->write);
86194 return;
86195 }
86196
86197 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86198 rb_event_set_padding(event);
86199
86200 /* Set the write back to the previous setting */
86201 - local_sub(length, &tail_page->write);
86202 + local_sub_unchecked(length, &tail_page->write);
86203 return;
86204 }
86205
86206 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86207
86208 /* Set write to end of buffer */
86209 length = (tail + length) - BUF_PAGE_SIZE;
86210 - local_sub(length, &tail_page->write);
86211 + local_sub_unchecked(length, &tail_page->write);
86212 }
86213
86214 /*
86215 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86216 * about it.
86217 */
86218 if (unlikely(next_page == commit_page)) {
86219 - local_inc(&cpu_buffer->commit_overrun);
86220 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86221 goto out_reset;
86222 }
86223
86224 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86225 cpu_buffer->tail_page) &&
86226 (cpu_buffer->commit_page ==
86227 cpu_buffer->reader_page))) {
86228 - local_inc(&cpu_buffer->commit_overrun);
86229 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86230 goto out_reset;
86231 }
86232 }
86233 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86234 length += RB_LEN_TIME_EXTEND;
86235
86236 tail_page = cpu_buffer->tail_page;
86237 - write = local_add_return(length, &tail_page->write);
86238 + write = local_add_return_unchecked(length, &tail_page->write);
86239
86240 /* set write to only the index of the write */
86241 write &= RB_WRITE_MASK;
86242 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86243 kmemcheck_annotate_bitfield(event, bitfield);
86244 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
86245
86246 - local_inc(&tail_page->entries);
86247 + local_inc_unchecked(&tail_page->entries);
86248
86249 /*
86250 * If this is the first commit on the page, then update
86251 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86252
86253 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
86254 unsigned long write_mask =
86255 - local_read(&bpage->write) & ~RB_WRITE_MASK;
86256 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
86257 unsigned long event_length = rb_event_length(event);
86258 /*
86259 * This is on the tail page. It is possible that
86260 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86261 */
86262 old_index += write_mask;
86263 new_index += write_mask;
86264 - index = local_cmpxchg(&bpage->write, old_index, new_index);
86265 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
86266 if (index == old_index) {
86267 /* update counters */
86268 local_sub(event_length, &cpu_buffer->entries_bytes);
86269 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86270
86271 /* Do the likely case first */
86272 if (likely(bpage->page == (void *)addr)) {
86273 - local_dec(&bpage->entries);
86274 + local_dec_unchecked(&bpage->entries);
86275 return;
86276 }
86277
86278 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86279 start = bpage;
86280 do {
86281 if (bpage->page == (void *)addr) {
86282 - local_dec(&bpage->entries);
86283 + local_dec_unchecked(&bpage->entries);
86284 return;
86285 }
86286 rb_inc_page(cpu_buffer, &bpage);
86287 @@ -3138,7 +3138,7 @@ static inline unsigned long
86288 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
86289 {
86290 return local_read(&cpu_buffer->entries) -
86291 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
86292 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
86293 }
86294
86295 /**
86296 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
86297 return 0;
86298
86299 cpu_buffer = buffer->buffers[cpu];
86300 - ret = local_read(&cpu_buffer->overrun);
86301 + ret = local_read_unchecked(&cpu_buffer->overrun);
86302
86303 return ret;
86304 }
86305 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
86306 return 0;
86307
86308 cpu_buffer = buffer->buffers[cpu];
86309 - ret = local_read(&cpu_buffer->commit_overrun);
86310 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
86311
86312 return ret;
86313 }
86314 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
86315 /* if you care about this being correct, lock the buffer */
86316 for_each_buffer_cpu(buffer, cpu) {
86317 cpu_buffer = buffer->buffers[cpu];
86318 - overruns += local_read(&cpu_buffer->overrun);
86319 + overruns += local_read_unchecked(&cpu_buffer->overrun);
86320 }
86321
86322 return overruns;
86323 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86324 /*
86325 * Reset the reader page to size zero.
86326 */
86327 - local_set(&cpu_buffer->reader_page->write, 0);
86328 - local_set(&cpu_buffer->reader_page->entries, 0);
86329 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86330 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86331 local_set(&cpu_buffer->reader_page->page->commit, 0);
86332 cpu_buffer->reader_page->real_end = 0;
86333
86334 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86335 * want to compare with the last_overrun.
86336 */
86337 smp_mb();
86338 - overwrite = local_read(&(cpu_buffer->overrun));
86339 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
86340
86341 /*
86342 * Here's the tricky part.
86343 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86344
86345 cpu_buffer->head_page
86346 = list_entry(cpu_buffer->pages, struct buffer_page, list);
86347 - local_set(&cpu_buffer->head_page->write, 0);
86348 - local_set(&cpu_buffer->head_page->entries, 0);
86349 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
86350 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
86351 local_set(&cpu_buffer->head_page->page->commit, 0);
86352
86353 cpu_buffer->head_page->read = 0;
86354 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86355
86356 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
86357 INIT_LIST_HEAD(&cpu_buffer->new_pages);
86358 - local_set(&cpu_buffer->reader_page->write, 0);
86359 - local_set(&cpu_buffer->reader_page->entries, 0);
86360 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86361 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86362 local_set(&cpu_buffer->reader_page->page->commit, 0);
86363 cpu_buffer->reader_page->read = 0;
86364
86365 local_set(&cpu_buffer->entries_bytes, 0);
86366 - local_set(&cpu_buffer->overrun, 0);
86367 - local_set(&cpu_buffer->commit_overrun, 0);
86368 + local_set_unchecked(&cpu_buffer->overrun, 0);
86369 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
86370 local_set(&cpu_buffer->dropped_events, 0);
86371 local_set(&cpu_buffer->entries, 0);
86372 local_set(&cpu_buffer->committing, 0);
86373 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
86374 rb_init_page(bpage);
86375 bpage = reader->page;
86376 reader->page = *data_page;
86377 - local_set(&reader->write, 0);
86378 - local_set(&reader->entries, 0);
86379 + local_set_unchecked(&reader->write, 0);
86380 + local_set_unchecked(&reader->entries, 0);
86381 reader->read = 0;
86382 *data_page = bpage;
86383
86384 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
86385 index 0582a01..310bed1 100644
86386 --- a/kernel/trace/trace.c
86387 +++ b/kernel/trace/trace.c
86388 @@ -3327,7 +3327,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
86389 return 0;
86390 }
86391
86392 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
86393 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
86394 {
86395 /* do nothing if flag is already set */
86396 if (!!(trace_flags & mask) == !!enabled)
86397 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
86398 index 51b4448..7be601f 100644
86399 --- a/kernel/trace/trace.h
86400 +++ b/kernel/trace/trace.h
86401 @@ -1035,7 +1035,7 @@ extern const char *__stop___trace_bprintk_fmt[];
86402 void trace_printk_init_buffers(void);
86403 void trace_printk_start_comm(void);
86404 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86405 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86406 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86407
86408 /*
86409 * Normal trace_printk() and friends allocates special buffers
86410 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86411 index 26dc348..8708ca7 100644
86412 --- a/kernel/trace/trace_clock.c
86413 +++ b/kernel/trace/trace_clock.c
86414 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86415 return now;
86416 }
86417
86418 -static atomic64_t trace_counter;
86419 +static atomic64_unchecked_t trace_counter;
86420
86421 /*
86422 * trace_clock_counter(): simply an atomic counter.
86423 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86424 */
86425 u64 notrace trace_clock_counter(void)
86426 {
86427 - return atomic64_add_return(1, &trace_counter);
86428 + return atomic64_inc_return_unchecked(&trace_counter);
86429 }
86430 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86431 index 3d18aad..d1be0eb 100644
86432 --- a/kernel/trace/trace_events.c
86433 +++ b/kernel/trace/trace_events.c
86434 @@ -1794,10 +1794,6 @@ static LIST_HEAD(ftrace_module_file_list);
86435 struct ftrace_module_file_ops {
86436 struct list_head list;
86437 struct module *mod;
86438 - struct file_operations id;
86439 - struct file_operations enable;
86440 - struct file_operations format;
86441 - struct file_operations filter;
86442 };
86443
86444 static struct ftrace_module_file_ops *
86445 @@ -1838,17 +1834,12 @@ trace_create_file_ops(struct module *mod)
86446
86447 file_ops->mod = mod;
86448
86449 - file_ops->id = ftrace_event_id_fops;
86450 - file_ops->id.owner = mod;
86451 -
86452 - file_ops->enable = ftrace_enable_fops;
86453 - file_ops->enable.owner = mod;
86454 -
86455 - file_ops->filter = ftrace_event_filter_fops;
86456 - file_ops->filter.owner = mod;
86457 -
86458 - file_ops->format = ftrace_event_format_fops;
86459 - file_ops->format.owner = mod;
86460 + pax_open_kernel();
86461 + mod->trace_id.owner = mod;
86462 + mod->trace_enable.owner = mod;
86463 + mod->trace_filter.owner = mod;
86464 + mod->trace_format.owner = mod;
86465 + pax_close_kernel();
86466
86467 list_add(&file_ops->list, &ftrace_module_file_list);
86468
86469 @@ -1941,8 +1932,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
86470 struct ftrace_module_file_ops *file_ops)
86471 {
86472 return __trace_add_new_event(call, tr,
86473 - &file_ops->id, &file_ops->enable,
86474 - &file_ops->filter, &file_ops->format);
86475 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
86476 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
86477 }
86478
86479 #else
86480 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86481 index a5e8f48..a9690d2 100644
86482 --- a/kernel/trace/trace_mmiotrace.c
86483 +++ b/kernel/trace/trace_mmiotrace.c
86484 @@ -24,7 +24,7 @@ struct header_iter {
86485 static struct trace_array *mmio_trace_array;
86486 static bool overrun_detected;
86487 static unsigned long prev_overruns;
86488 -static atomic_t dropped_count;
86489 +static atomic_unchecked_t dropped_count;
86490
86491 static void mmio_reset_data(struct trace_array *tr)
86492 {
86493 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86494
86495 static unsigned long count_overruns(struct trace_iterator *iter)
86496 {
86497 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86498 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86499 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86500
86501 if (over > prev_overruns)
86502 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86503 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86504 sizeof(*entry), 0, pc);
86505 if (!event) {
86506 - atomic_inc(&dropped_count);
86507 + atomic_inc_unchecked(&dropped_count);
86508 return;
86509 }
86510 entry = ring_buffer_event_data(event);
86511 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86512 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86513 sizeof(*entry), 0, pc);
86514 if (!event) {
86515 - atomic_inc(&dropped_count);
86516 + atomic_inc_unchecked(&dropped_count);
86517 return;
86518 }
86519 entry = ring_buffer_event_data(event);
86520 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86521 index bb922d9..2a54a257 100644
86522 --- a/kernel/trace/trace_output.c
86523 +++ b/kernel/trace/trace_output.c
86524 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86525
86526 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86527 if (!IS_ERR(p)) {
86528 - p = mangle_path(s->buffer + s->len, p, "\n");
86529 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86530 if (p) {
86531 s->len = p - s->buffer;
86532 return 1;
86533 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86534 goto out;
86535 }
86536
86537 + pax_open_kernel();
86538 if (event->funcs->trace == NULL)
86539 - event->funcs->trace = trace_nop_print;
86540 + *(void **)&event->funcs->trace = trace_nop_print;
86541 if (event->funcs->raw == NULL)
86542 - event->funcs->raw = trace_nop_print;
86543 + *(void **)&event->funcs->raw = trace_nop_print;
86544 if (event->funcs->hex == NULL)
86545 - event->funcs->hex = trace_nop_print;
86546 + *(void **)&event->funcs->hex = trace_nop_print;
86547 if (event->funcs->binary == NULL)
86548 - event->funcs->binary = trace_nop_print;
86549 + *(void **)&event->funcs->binary = trace_nop_print;
86550 + pax_close_kernel();
86551
86552 key = event->type & (EVENT_HASHSIZE - 1);
86553
86554 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86555 index b20428c..4845a10 100644
86556 --- a/kernel/trace/trace_stack.c
86557 +++ b/kernel/trace/trace_stack.c
86558 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86559 return;
86560
86561 /* we do not handle interrupt stacks yet */
86562 - if (!object_is_on_stack(stack))
86563 + if (!object_starts_on_stack(stack))
86564 return;
86565
86566 local_irq_save(flags);
86567 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86568 index 9064b91..1f5d2f8 100644
86569 --- a/kernel/user_namespace.c
86570 +++ b/kernel/user_namespace.c
86571 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86572 !kgid_has_mapping(parent_ns, group))
86573 return -EPERM;
86574
86575 +#ifdef CONFIG_GRKERNSEC
86576 + /*
86577 + * This doesn't really inspire confidence:
86578 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86579 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86580 + * Increases kernel attack surface in areas developers
86581 + * previously cared little about ("low importance due
86582 + * to requiring "root" capability")
86583 + * To be removed when this code receives *proper* review
86584 + */
86585 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86586 + !capable(CAP_SETGID))
86587 + return -EPERM;
86588 +#endif
86589 +
86590 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86591 if (!ns)
86592 return -ENOMEM;
86593 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86594 if (atomic_read(&current->mm->mm_users) > 1)
86595 return -EINVAL;
86596
86597 - if (current->fs->users != 1)
86598 + if (atomic_read(&current->fs->users) != 1)
86599 return -EINVAL;
86600
86601 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86602 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86603 index 4f69f9a..7c6f8f8 100644
86604 --- a/kernel/utsname_sysctl.c
86605 +++ b/kernel/utsname_sysctl.c
86606 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86607 static int proc_do_uts_string(ctl_table *table, int write,
86608 void __user *buffer, size_t *lenp, loff_t *ppos)
86609 {
86610 - struct ctl_table uts_table;
86611 + ctl_table_no_const uts_table;
86612 int r;
86613 memcpy(&uts_table, table, sizeof(uts_table));
86614 uts_table.data = get_uts(table, write);
86615 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86616 index 05039e3..17490c7 100644
86617 --- a/kernel/watchdog.c
86618 +++ b/kernel/watchdog.c
86619 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
86620 }
86621 #endif /* CONFIG_SYSCTL */
86622
86623 -static struct smp_hotplug_thread watchdog_threads = {
86624 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86625 .store = &softlockup_watchdog,
86626 .thread_should_run = watchdog_should_run,
86627 .thread_fn = watchdog,
86628 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86629 index 6f01921..139869b 100644
86630 --- a/kernel/workqueue.c
86631 +++ b/kernel/workqueue.c
86632 @@ -4596,7 +4596,7 @@ static void rebind_workers(struct worker_pool *pool)
86633 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86634 worker_flags |= WORKER_REBOUND;
86635 worker_flags &= ~WORKER_UNBOUND;
86636 - ACCESS_ONCE(worker->flags) = worker_flags;
86637 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86638 }
86639
86640 spin_unlock_irq(&pool->lock);
86641 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86642 index 74fdc5c..3310593 100644
86643 --- a/lib/Kconfig.debug
86644 +++ b/lib/Kconfig.debug
86645 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
86646
86647 config DEBUG_LOCK_ALLOC
86648 bool "Lock debugging: detect incorrect freeing of live locks"
86649 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86650 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86651 select DEBUG_SPINLOCK
86652 select DEBUG_MUTEXES
86653 select LOCKDEP
86654 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
86655
86656 config PROVE_LOCKING
86657 bool "Lock debugging: prove locking correctness"
86658 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86659 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86660 select LOCKDEP
86661 select DEBUG_SPINLOCK
86662 select DEBUG_MUTEXES
86663 @@ -614,7 +614,7 @@ config LOCKDEP
86664
86665 config LOCK_STAT
86666 bool "Lock usage statistics"
86667 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86668 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86669 select LOCKDEP
86670 select DEBUG_SPINLOCK
86671 select DEBUG_MUTEXES
86672 @@ -1282,6 +1282,7 @@ config LATENCYTOP
86673 depends on DEBUG_KERNEL
86674 depends on STACKTRACE_SUPPORT
86675 depends on PROC_FS
86676 + depends on !GRKERNSEC_HIDESYM
86677 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
86678 select KALLSYMS
86679 select KALLSYMS_ALL
86680 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86681 config DEBUG_STRICT_USER_COPY_CHECKS
86682 bool "Strict user copy size checks"
86683 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86684 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
86685 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
86686 help
86687 Enabling this option turns a certain set of sanity checks for user
86688 copy operations into compile time failures.
86689 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
86690
86691 config PROVIDE_OHCI1394_DMA_INIT
86692 bool "Remote debugging over FireWire early on boot"
86693 - depends on PCI && X86
86694 + depends on PCI && X86 && !GRKERNSEC
86695 help
86696 If you want to debug problems which hang or crash the kernel early
86697 on boot and the crashing machine has a FireWire port, you can use
86698 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
86699
86700 config FIREWIRE_OHCI_REMOTE_DMA
86701 bool "Remote debugging over FireWire with firewire-ohci"
86702 - depends on FIREWIRE_OHCI
86703 + depends on FIREWIRE_OHCI && !GRKERNSEC
86704 help
86705 This option lets you use the FireWire bus for remote debugging
86706 with help of the firewire-ohci driver. It enables unfiltered
86707 diff --git a/lib/Makefile b/lib/Makefile
86708 index c55a037..fb46e3b 100644
86709 --- a/lib/Makefile
86710 +++ b/lib/Makefile
86711 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
86712
86713 obj-$(CONFIG_BTREE) += btree.o
86714 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
86715 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
86716 +obj-y += list_debug.o
86717 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
86718
86719 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
86720 diff --git a/lib/bitmap.c b/lib/bitmap.c
86721 index 06f7e4f..f3cf2b0 100644
86722 --- a/lib/bitmap.c
86723 +++ b/lib/bitmap.c
86724 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
86725 {
86726 int c, old_c, totaldigits, ndigits, nchunks, nbits;
86727 u32 chunk;
86728 - const char __user __force *ubuf = (const char __user __force *)buf;
86729 + const char __user *ubuf = (const char __force_user *)buf;
86730
86731 bitmap_zero(maskp, nmaskbits);
86732
86733 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
86734 {
86735 if (!access_ok(VERIFY_READ, ubuf, ulen))
86736 return -EFAULT;
86737 - return __bitmap_parse((const char __force *)ubuf,
86738 + return __bitmap_parse((const char __force_kernel *)ubuf,
86739 ulen, 1, maskp, nmaskbits);
86740
86741 }
86742 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
86743 {
86744 unsigned a, b;
86745 int c, old_c, totaldigits;
86746 - const char __user __force *ubuf = (const char __user __force *)buf;
86747 + const char __user *ubuf = (const char __force_user *)buf;
86748 int exp_digit, in_range;
86749
86750 totaldigits = c = 0;
86751 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
86752 {
86753 if (!access_ok(VERIFY_READ, ubuf, ulen))
86754 return -EFAULT;
86755 - return __bitmap_parselist((const char __force *)ubuf,
86756 + return __bitmap_parselist((const char __force_kernel *)ubuf,
86757 ulen, 1, maskp, nmaskbits);
86758 }
86759 EXPORT_SYMBOL(bitmap_parselist_user);
86760 diff --git a/lib/bug.c b/lib/bug.c
86761 index 1686034..a9c00c8 100644
86762 --- a/lib/bug.c
86763 +++ b/lib/bug.c
86764 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
86765 return BUG_TRAP_TYPE_NONE;
86766
86767 bug = find_bug(bugaddr);
86768 + if (!bug)
86769 + return BUG_TRAP_TYPE_NONE;
86770
86771 file = NULL;
86772 line = 0;
86773 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
86774 index 37061ed..da83f48 100644
86775 --- a/lib/debugobjects.c
86776 +++ b/lib/debugobjects.c
86777 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
86778 if (limit > 4)
86779 return;
86780
86781 - is_on_stack = object_is_on_stack(addr);
86782 + is_on_stack = object_starts_on_stack(addr);
86783 if (is_on_stack == onstack)
86784 return;
86785
86786 diff --git a/lib/devres.c b/lib/devres.c
86787 index 8235331..5881053 100644
86788 --- a/lib/devres.c
86789 +++ b/lib/devres.c
86790 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
86791 void devm_iounmap(struct device *dev, void __iomem *addr)
86792 {
86793 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
86794 - (void *)addr));
86795 + (void __force *)addr));
86796 iounmap(addr);
86797 }
86798 EXPORT_SYMBOL(devm_iounmap);
86799 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
86800 {
86801 ioport_unmap(addr);
86802 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
86803 - devm_ioport_map_match, (void *)addr));
86804 + devm_ioport_map_match, (void __force *)addr));
86805 }
86806 EXPORT_SYMBOL(devm_ioport_unmap);
86807 #endif /* CONFIG_HAS_IOPORT */
86808 diff --git a/lib/div64.c b/lib/div64.c
86809 index a163b6c..9618fa5 100644
86810 --- a/lib/div64.c
86811 +++ b/lib/div64.c
86812 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
86813 EXPORT_SYMBOL(__div64_32);
86814
86815 #ifndef div_s64_rem
86816 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86817 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86818 {
86819 u64 quotient;
86820
86821 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
86822 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
86823 */
86824 #ifndef div64_u64
86825 -u64 div64_u64(u64 dividend, u64 divisor)
86826 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
86827 {
86828 u32 high = divisor >> 32;
86829 u64 quot;
86830 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
86831 index d87a17a..ac0d79a 100644
86832 --- a/lib/dma-debug.c
86833 +++ b/lib/dma-debug.c
86834 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
86835
86836 void dma_debug_add_bus(struct bus_type *bus)
86837 {
86838 - struct notifier_block *nb;
86839 + notifier_block_no_const *nb;
86840
86841 if (global_disable)
86842 return;
86843 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
86844
86845 static void check_for_stack(struct device *dev, void *addr)
86846 {
86847 - if (object_is_on_stack(addr))
86848 + if (object_starts_on_stack(addr))
86849 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
86850 "stack [addr=%p]\n", addr);
86851 }
86852 diff --git a/lib/inflate.c b/lib/inflate.c
86853 index 013a761..c28f3fc 100644
86854 --- a/lib/inflate.c
86855 +++ b/lib/inflate.c
86856 @@ -269,7 +269,7 @@ static void free(void *where)
86857 malloc_ptr = free_mem_ptr;
86858 }
86859 #else
86860 -#define malloc(a) kmalloc(a, GFP_KERNEL)
86861 +#define malloc(a) kmalloc((a), GFP_KERNEL)
86862 #define free(a) kfree(a)
86863 #endif
86864
86865 diff --git a/lib/ioremap.c b/lib/ioremap.c
86866 index 0c9216c..863bd89 100644
86867 --- a/lib/ioremap.c
86868 +++ b/lib/ioremap.c
86869 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
86870 unsigned long next;
86871
86872 phys_addr -= addr;
86873 - pmd = pmd_alloc(&init_mm, pud, addr);
86874 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86875 if (!pmd)
86876 return -ENOMEM;
86877 do {
86878 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
86879 unsigned long next;
86880
86881 phys_addr -= addr;
86882 - pud = pud_alloc(&init_mm, pgd, addr);
86883 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86884 if (!pud)
86885 return -ENOMEM;
86886 do {
86887 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
86888 index bd2bea9..6b3c95e 100644
86889 --- a/lib/is_single_threaded.c
86890 +++ b/lib/is_single_threaded.c
86891 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
86892 struct task_struct *p, *t;
86893 bool ret;
86894
86895 + if (!mm)
86896 + return true;
86897 +
86898 if (atomic_read(&task->signal->live) != 1)
86899 return false;
86900
86901 diff --git a/lib/kobject.c b/lib/kobject.c
86902 index b7e29a6..2f3ca75 100644
86903 --- a/lib/kobject.c
86904 +++ b/lib/kobject.c
86905 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
86906 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
86907 if (!kset)
86908 return NULL;
86909 - retval = kobject_set_name(&kset->kobj, name);
86910 + retval = kobject_set_name(&kset->kobj, "%s", name);
86911 if (retval) {
86912 kfree(kset);
86913 return NULL;
86914 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
86915
86916
86917 static DEFINE_SPINLOCK(kobj_ns_type_lock);
86918 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
86919 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
86920
86921 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86922 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86923 {
86924 enum kobj_ns_type type = ops->type;
86925 int error;
86926 diff --git a/lib/list_debug.c b/lib/list_debug.c
86927 index c24c2f7..06e070b 100644
86928 --- a/lib/list_debug.c
86929 +++ b/lib/list_debug.c
86930 @@ -11,7 +11,9 @@
86931 #include <linux/bug.h>
86932 #include <linux/kernel.h>
86933 #include <linux/rculist.h>
86934 +#include <linux/mm.h>
86935
86936 +#ifdef CONFIG_DEBUG_LIST
86937 /*
86938 * Insert a new entry between two known consecutive entries.
86939 *
86940 @@ -19,21 +21,32 @@
86941 * the prev/next entries already!
86942 */
86943
86944 -void __list_add(struct list_head *new,
86945 - struct list_head *prev,
86946 - struct list_head *next)
86947 +static bool __list_add_debug(struct list_head *new,
86948 + struct list_head *prev,
86949 + struct list_head *next)
86950 {
86951 - WARN(next->prev != prev,
86952 + if (WARN(next->prev != prev,
86953 "list_add corruption. next->prev should be "
86954 "prev (%p), but was %p. (next=%p).\n",
86955 - prev, next->prev, next);
86956 - WARN(prev->next != next,
86957 + prev, next->prev, next) ||
86958 + WARN(prev->next != next,
86959 "list_add corruption. prev->next should be "
86960 "next (%p), but was %p. (prev=%p).\n",
86961 - next, prev->next, prev);
86962 - WARN(new == prev || new == next,
86963 - "list_add double add: new=%p, prev=%p, next=%p.\n",
86964 - new, prev, next);
86965 + next, prev->next, prev) ||
86966 + WARN(new == prev || new == next,
86967 + "list_add double add: new=%p, prev=%p, next=%p.\n",
86968 + new, prev, next))
86969 + return false;
86970 + return true;
86971 +}
86972 +
86973 +void __list_add(struct list_head *new,
86974 + struct list_head *prev,
86975 + struct list_head *next)
86976 +{
86977 + if (!__list_add_debug(new, prev, next))
86978 + return;
86979 +
86980 next->prev = new;
86981 new->next = next;
86982 new->prev = prev;
86983 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
86984 }
86985 EXPORT_SYMBOL(__list_add);
86986
86987 -void __list_del_entry(struct list_head *entry)
86988 +static bool __list_del_entry_debug(struct list_head *entry)
86989 {
86990 struct list_head *prev, *next;
86991
86992 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
86993 WARN(next->prev != entry,
86994 "list_del corruption. next->prev should be %p, "
86995 "but was %p\n", entry, next->prev))
86996 + return false;
86997 + return true;
86998 +}
86999 +
87000 +void __list_del_entry(struct list_head *entry)
87001 +{
87002 + if (!__list_del_entry_debug(entry))
87003 return;
87004
87005 - __list_del(prev, next);
87006 + __list_del(entry->prev, entry->next);
87007 }
87008 EXPORT_SYMBOL(__list_del_entry);
87009
87010 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
87011 void __list_add_rcu(struct list_head *new,
87012 struct list_head *prev, struct list_head *next)
87013 {
87014 - WARN(next->prev != prev,
87015 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
87016 - prev, next->prev, next);
87017 - WARN(prev->next != next,
87018 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
87019 - next, prev->next, prev);
87020 + if (!__list_add_debug(new, prev, next))
87021 + return;
87022 +
87023 new->next = next;
87024 new->prev = prev;
87025 rcu_assign_pointer(list_next_rcu(prev), new);
87026 next->prev = new;
87027 }
87028 EXPORT_SYMBOL(__list_add_rcu);
87029 +#endif
87030 +
87031 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
87032 +{
87033 +#ifdef CONFIG_DEBUG_LIST
87034 + if (!__list_add_debug(new, prev, next))
87035 + return;
87036 +#endif
87037 +
87038 + pax_open_kernel();
87039 + next->prev = new;
87040 + new->next = next;
87041 + new->prev = prev;
87042 + prev->next = new;
87043 + pax_close_kernel();
87044 +}
87045 +EXPORT_SYMBOL(__pax_list_add);
87046 +
87047 +void pax_list_del(struct list_head *entry)
87048 +{
87049 +#ifdef CONFIG_DEBUG_LIST
87050 + if (!__list_del_entry_debug(entry))
87051 + return;
87052 +#endif
87053 +
87054 + pax_open_kernel();
87055 + __list_del(entry->prev, entry->next);
87056 + entry->next = LIST_POISON1;
87057 + entry->prev = LIST_POISON2;
87058 + pax_close_kernel();
87059 +}
87060 +EXPORT_SYMBOL(pax_list_del);
87061 +
87062 +void pax_list_del_init(struct list_head *entry)
87063 +{
87064 + pax_open_kernel();
87065 + __list_del(entry->prev, entry->next);
87066 + INIT_LIST_HEAD(entry);
87067 + pax_close_kernel();
87068 +}
87069 +EXPORT_SYMBOL(pax_list_del_init);
87070 +
87071 +void __pax_list_add_rcu(struct list_head *new,
87072 + struct list_head *prev, struct list_head *next)
87073 +{
87074 +#ifdef CONFIG_DEBUG_LIST
87075 + if (!__list_add_debug(new, prev, next))
87076 + return;
87077 +#endif
87078 +
87079 + pax_open_kernel();
87080 + new->next = next;
87081 + new->prev = prev;
87082 + rcu_assign_pointer(list_next_rcu(prev), new);
87083 + next->prev = new;
87084 + pax_close_kernel();
87085 +}
87086 +EXPORT_SYMBOL(__pax_list_add_rcu);
87087 +
87088 +void pax_list_del_rcu(struct list_head *entry)
87089 +{
87090 +#ifdef CONFIG_DEBUG_LIST
87091 + if (!__list_del_entry_debug(entry))
87092 + return;
87093 +#endif
87094 +
87095 + pax_open_kernel();
87096 + __list_del(entry->prev, entry->next);
87097 + entry->next = LIST_POISON1;
87098 + entry->prev = LIST_POISON2;
87099 + pax_close_kernel();
87100 +}
87101 +EXPORT_SYMBOL(pax_list_del_rcu);
87102 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
87103 index e796429..6e38f9f 100644
87104 --- a/lib/radix-tree.c
87105 +++ b/lib/radix-tree.c
87106 @@ -92,7 +92,7 @@ struct radix_tree_preload {
87107 int nr;
87108 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
87109 };
87110 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
87111 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
87112
87113 static inline void *ptr_to_indirect(void *ptr)
87114 {
87115 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
87116 index bb2b201..46abaf9 100644
87117 --- a/lib/strncpy_from_user.c
87118 +++ b/lib/strncpy_from_user.c
87119 @@ -21,7 +21,7 @@
87120 */
87121 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
87122 {
87123 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87124 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87125 long res = 0;
87126
87127 /*
87128 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
87129 index a28df52..3d55877 100644
87130 --- a/lib/strnlen_user.c
87131 +++ b/lib/strnlen_user.c
87132 @@ -26,7 +26,7 @@
87133 */
87134 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
87135 {
87136 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87137 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87138 long align, res = 0;
87139 unsigned long c;
87140
87141 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
87142 index d23762e..e21eab2 100644
87143 --- a/lib/swiotlb.c
87144 +++ b/lib/swiotlb.c
87145 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
87146
87147 void
87148 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
87149 - dma_addr_t dev_addr)
87150 + dma_addr_t dev_addr, struct dma_attrs *attrs)
87151 {
87152 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
87153
87154 diff --git a/lib/usercopy.c b/lib/usercopy.c
87155 index 4f5b1dd..7cab418 100644
87156 --- a/lib/usercopy.c
87157 +++ b/lib/usercopy.c
87158 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
87159 WARN(1, "Buffer overflow detected!\n");
87160 }
87161 EXPORT_SYMBOL(copy_from_user_overflow);
87162 +
87163 +void copy_to_user_overflow(void)
87164 +{
87165 + WARN(1, "Buffer overflow detected!\n");
87166 +}
87167 +EXPORT_SYMBOL(copy_to_user_overflow);
87168 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
87169 index e149c64..24aa71a 100644
87170 --- a/lib/vsprintf.c
87171 +++ b/lib/vsprintf.c
87172 @@ -16,6 +16,9 @@
87173 * - scnprintf and vscnprintf
87174 */
87175
87176 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87177 +#define __INCLUDED_BY_HIDESYM 1
87178 +#endif
87179 #include <stdarg.h>
87180 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
87181 #include <linux/types.h>
87182 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
87183 return number(buf, end, *(const netdev_features_t *)addr, spec);
87184 }
87185
87186 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87187 +int kptr_restrict __read_mostly = 2;
87188 +#else
87189 int kptr_restrict __read_mostly;
87190 +#endif
87191
87192 /*
87193 * Show a '%p' thing. A kernel extension is that the '%p' is followed
87194 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
87195 * - 'f' For simple symbolic function names without offset
87196 * - 'S' For symbolic direct pointers with offset
87197 * - 's' For symbolic direct pointers without offset
87198 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
87199 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
87200 * - 'B' For backtraced symbolic direct pointers with offset
87201 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
87202 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87203
87204 if (!ptr && *fmt != 'K') {
87205 /*
87206 - * Print (null) with the same width as a pointer so it makes
87207 + * Print (nil) with the same width as a pointer so it makes
87208 * tabular output look nice.
87209 */
87210 if (spec.field_width == -1)
87211 spec.field_width = default_width;
87212 - return string(buf, end, "(null)", spec);
87213 + return string(buf, end, "(nil)", spec);
87214 }
87215
87216 switch (*fmt) {
87217 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87218 /* Fallthrough */
87219 case 'S':
87220 case 's':
87221 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87222 + break;
87223 +#else
87224 + return symbol_string(buf, end, ptr, spec, fmt);
87225 +#endif
87226 + case 'A':
87227 case 'B':
87228 return symbol_string(buf, end, ptr, spec, fmt);
87229 case 'R':
87230 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87231 va_end(va);
87232 return buf;
87233 }
87234 + case 'P':
87235 + break;
87236 case 'K':
87237 /*
87238 * %pK cannot be used in IRQ context because its test
87239 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87240 return number(buf, end,
87241 (unsigned long long) *((phys_addr_t *)ptr), spec);
87242 }
87243 +
87244 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87245 + /* 'P' = approved pointers to copy to userland,
87246 + as in the /proc/kallsyms case, as we make it display nothing
87247 + for non-root users, and the real contents for root users
87248 + Also ignore 'K' pointers, since we force their NULLing for non-root users
87249 + above
87250 + */
87251 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
87252 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
87253 + dump_stack();
87254 + ptr = NULL;
87255 + }
87256 +#endif
87257 +
87258 spec.flags |= SMALL;
87259 if (spec.field_width == -1) {
87260 spec.field_width = default_width;
87261 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87262 typeof(type) value; \
87263 if (sizeof(type) == 8) { \
87264 args = PTR_ALIGN(args, sizeof(u32)); \
87265 - *(u32 *)&value = *(u32 *)args; \
87266 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
87267 + *(u32 *)&value = *(const u32 *)args; \
87268 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
87269 } else { \
87270 args = PTR_ALIGN(args, sizeof(type)); \
87271 - value = *(typeof(type) *)args; \
87272 + value = *(const typeof(type) *)args; \
87273 } \
87274 args += sizeof(type); \
87275 value; \
87276 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87277 case FORMAT_TYPE_STR: {
87278 const char *str_arg = args;
87279 args += strlen(str_arg) + 1;
87280 - str = string(str, end, (char *)str_arg, spec);
87281 + str = string(str, end, str_arg, spec);
87282 break;
87283 }
87284
87285 diff --git a/localversion-grsec b/localversion-grsec
87286 new file mode 100644
87287 index 0000000..7cd6065
87288 --- /dev/null
87289 +++ b/localversion-grsec
87290 @@ -0,0 +1 @@
87291 +-grsec
87292 diff --git a/mm/Kconfig b/mm/Kconfig
87293 index e742d06..c56fdd8 100644
87294 --- a/mm/Kconfig
87295 +++ b/mm/Kconfig
87296 @@ -317,10 +317,10 @@ config KSM
87297 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
87298
87299 config DEFAULT_MMAP_MIN_ADDR
87300 - int "Low address space to protect from user allocation"
87301 + int "Low address space to protect from user allocation"
87302 depends on MMU
87303 - default 4096
87304 - help
87305 + default 65536
87306 + help
87307 This is the portion of low virtual memory which should be protected
87308 from userspace allocation. Keeping a user from writing to low pages
87309 can help reduce the impact of kernel NULL pointer bugs.
87310 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
87311
87312 config HWPOISON_INJECT
87313 tristate "HWPoison pages injector"
87314 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
87315 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
87316 select PROC_PAGE_MONITOR
87317
87318 config NOMMU_INITIAL_TRIM_EXCESS
87319 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
87320 index 5025174..9d67dcd 100644
87321 --- a/mm/backing-dev.c
87322 +++ b/mm/backing-dev.c
87323 @@ -12,7 +12,7 @@
87324 #include <linux/device.h>
87325 #include <trace/events/writeback.h>
87326
87327 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
87328 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
87329
87330 struct backing_dev_info default_backing_dev_info = {
87331 .name = "default",
87332 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
87333 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
87334 unsigned int cap)
87335 {
87336 - char tmp[32];
87337 int err;
87338
87339 bdi->name = name;
87340 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
87341 if (err)
87342 return err;
87343
87344 - sprintf(tmp, "%.28s%s", name, "-%d");
87345 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
87346 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return_unchecked(&bdi_seq));
87347 if (err) {
87348 bdi_destroy(bdi);
87349 return err;
87350 diff --git a/mm/filemap.c b/mm/filemap.c
87351 index 7905fe7..f59502b 100644
87352 --- a/mm/filemap.c
87353 +++ b/mm/filemap.c
87354 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
87355 struct address_space *mapping = file->f_mapping;
87356
87357 if (!mapping->a_ops->readpage)
87358 - return -ENOEXEC;
87359 + return -ENODEV;
87360 file_accessed(file);
87361 vma->vm_ops = &generic_file_vm_ops;
87362 return 0;
87363 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
87364
87365 while (bytes) {
87366 char __user *buf = iov->iov_base + base;
87367 - int copy = min(bytes, iov->iov_len - base);
87368 + size_t copy = min(bytes, iov->iov_len - base);
87369
87370 base = 0;
87371 left = __copy_from_user_inatomic(vaddr, buf, copy);
87372 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
87373 BUG_ON(!in_atomic());
87374 kaddr = kmap_atomic(page);
87375 if (likely(i->nr_segs == 1)) {
87376 - int left;
87377 + size_t left;
87378 char __user *buf = i->iov->iov_base + i->iov_offset;
87379 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
87380 copied = bytes - left;
87381 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
87382
87383 kaddr = kmap(page);
87384 if (likely(i->nr_segs == 1)) {
87385 - int left;
87386 + size_t left;
87387 char __user *buf = i->iov->iov_base + i->iov_offset;
87388 left = __copy_from_user(kaddr + offset, buf, bytes);
87389 copied = bytes - left;
87390 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87391 * zero-length segments (without overruning the iovec).
87392 */
87393 while (bytes || unlikely(i->count && !iov->iov_len)) {
87394 - int copy;
87395 + size_t copy;
87396
87397 copy = min(bytes, iov->iov_len - base);
87398 BUG_ON(!i->count || i->count < copy);
87399 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87400 *pos = i_size_read(inode);
87401
87402 if (limit != RLIM_INFINITY) {
87403 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87404 if (*pos >= limit) {
87405 send_sig(SIGXFSZ, current, 0);
87406 return -EFBIG;
87407 diff --git a/mm/fremap.c b/mm/fremap.c
87408 index 87da359..3f41cb1 100644
87409 --- a/mm/fremap.c
87410 +++ b/mm/fremap.c
87411 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87412 retry:
87413 vma = find_vma(mm, start);
87414
87415 +#ifdef CONFIG_PAX_SEGMEXEC
87416 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87417 + goto out;
87418 +#endif
87419 +
87420 /*
87421 * Make sure the vma is shared, that it supports prefaulting,
87422 * and that the remapped range is valid and fully within
87423 diff --git a/mm/highmem.c b/mm/highmem.c
87424 index b32b70c..e512eb0 100644
87425 --- a/mm/highmem.c
87426 +++ b/mm/highmem.c
87427 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87428 * So no dangers, even with speculative execution.
87429 */
87430 page = pte_page(pkmap_page_table[i]);
87431 + pax_open_kernel();
87432 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87433 -
87434 + pax_close_kernel();
87435 set_page_address(page, NULL);
87436 need_flush = 1;
87437 }
87438 @@ -198,9 +199,11 @@ start:
87439 }
87440 }
87441 vaddr = PKMAP_ADDR(last_pkmap_nr);
87442 +
87443 + pax_open_kernel();
87444 set_pte_at(&init_mm, vaddr,
87445 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87446 -
87447 + pax_close_kernel();
87448 pkmap_count[last_pkmap_nr] = 1;
87449 set_page_address(page, (void *)vaddr);
87450
87451 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87452 index 7c5eb85..5c01c2f 100644
87453 --- a/mm/hugetlb.c
87454 +++ b/mm/hugetlb.c
87455 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87456 struct hstate *h = &default_hstate;
87457 unsigned long tmp;
87458 int ret;
87459 + ctl_table_no_const hugetlb_table;
87460
87461 tmp = h->max_huge_pages;
87462
87463 if (write && h->order >= MAX_ORDER)
87464 return -EINVAL;
87465
87466 - table->data = &tmp;
87467 - table->maxlen = sizeof(unsigned long);
87468 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87469 + hugetlb_table = *table;
87470 + hugetlb_table.data = &tmp;
87471 + hugetlb_table.maxlen = sizeof(unsigned long);
87472 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87473 if (ret)
87474 goto out;
87475
87476 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87477 struct hstate *h = &default_hstate;
87478 unsigned long tmp;
87479 int ret;
87480 + ctl_table_no_const hugetlb_table;
87481
87482 tmp = h->nr_overcommit_huge_pages;
87483
87484 if (write && h->order >= MAX_ORDER)
87485 return -EINVAL;
87486
87487 - table->data = &tmp;
87488 - table->maxlen = sizeof(unsigned long);
87489 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87490 + hugetlb_table = *table;
87491 + hugetlb_table.data = &tmp;
87492 + hugetlb_table.maxlen = sizeof(unsigned long);
87493 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87494 if (ret)
87495 goto out;
87496
87497 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87498 return 1;
87499 }
87500
87501 +#ifdef CONFIG_PAX_SEGMEXEC
87502 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87503 +{
87504 + struct mm_struct *mm = vma->vm_mm;
87505 + struct vm_area_struct *vma_m;
87506 + unsigned long address_m;
87507 + pte_t *ptep_m;
87508 +
87509 + vma_m = pax_find_mirror_vma(vma);
87510 + if (!vma_m)
87511 + return;
87512 +
87513 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87514 + address_m = address + SEGMEXEC_TASK_SIZE;
87515 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87516 + get_page(page_m);
87517 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87518 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87519 +}
87520 +#endif
87521 +
87522 /*
87523 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87524 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87525 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
87526 make_huge_pte(vma, new_page, 1));
87527 page_remove_rmap(old_page);
87528 hugepage_add_new_anon_rmap(new_page, vma, address);
87529 +
87530 +#ifdef CONFIG_PAX_SEGMEXEC
87531 + pax_mirror_huge_pte(vma, address, new_page);
87532 +#endif
87533 +
87534 /* Make the old page be freed below */
87535 new_page = old_page;
87536 }
87537 @@ -2821,6 +2851,10 @@ retry:
87538 && (vma->vm_flags & VM_SHARED)));
87539 set_huge_pte_at(mm, address, ptep, new_pte);
87540
87541 +#ifdef CONFIG_PAX_SEGMEXEC
87542 + pax_mirror_huge_pte(vma, address, page);
87543 +#endif
87544 +
87545 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87546 /* Optimization, do the COW without a second fault */
87547 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87548 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87549 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87550 struct hstate *h = hstate_vma(vma);
87551
87552 +#ifdef CONFIG_PAX_SEGMEXEC
87553 + struct vm_area_struct *vma_m;
87554 +#endif
87555 +
87556 address &= huge_page_mask(h);
87557
87558 ptep = huge_pte_offset(mm, address);
87559 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87560 VM_FAULT_SET_HINDEX(hstate_index(h));
87561 }
87562
87563 +#ifdef CONFIG_PAX_SEGMEXEC
87564 + vma_m = pax_find_mirror_vma(vma);
87565 + if (vma_m) {
87566 + unsigned long address_m;
87567 +
87568 + if (vma->vm_start > vma_m->vm_start) {
87569 + address_m = address;
87570 + address -= SEGMEXEC_TASK_SIZE;
87571 + vma = vma_m;
87572 + h = hstate_vma(vma);
87573 + } else
87574 + address_m = address + SEGMEXEC_TASK_SIZE;
87575 +
87576 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
87577 + return VM_FAULT_OOM;
87578 + address_m &= HPAGE_MASK;
87579 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
87580 + }
87581 +#endif
87582 +
87583 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
87584 if (!ptep)
87585 return VM_FAULT_OOM;
87586 diff --git a/mm/internal.h b/mm/internal.h
87587 index 8562de0..92b2073 100644
87588 --- a/mm/internal.h
87589 +++ b/mm/internal.h
87590 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
87591 * in mm/page_alloc.c
87592 */
87593 extern void __free_pages_bootmem(struct page *page, unsigned int order);
87594 +extern void free_compound_page(struct page *page);
87595 extern void prep_compound_page(struct page *page, unsigned long order);
87596 #ifdef CONFIG_MEMORY_FAILURE
87597 extern bool is_free_buddy_page(struct page *page);
87598 @@ -355,7 +356,7 @@ extern u32 hwpoison_filter_enable;
87599
87600 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
87601 unsigned long, unsigned long,
87602 - unsigned long, unsigned long);
87603 + unsigned long, unsigned long) __intentional_overflow(-1);
87604
87605 extern void set_pageblock_order(void);
87606 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
87607 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
87608 index c8d7f31..2dbeffd 100644
87609 --- a/mm/kmemleak.c
87610 +++ b/mm/kmemleak.c
87611 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
87612
87613 for (i = 0; i < object->trace_len; i++) {
87614 void *ptr = (void *)object->trace[i];
87615 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
87616 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
87617 }
87618 }
87619
87620 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
87621 return -ENOMEM;
87622 }
87623
87624 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
87625 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
87626 &kmemleak_fops);
87627 if (!dentry)
87628 pr_warning("Failed to create the debugfs kmemleak file\n");
87629 diff --git a/mm/maccess.c b/mm/maccess.c
87630 index d53adf9..03a24bf 100644
87631 --- a/mm/maccess.c
87632 +++ b/mm/maccess.c
87633 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
87634 set_fs(KERNEL_DS);
87635 pagefault_disable();
87636 ret = __copy_from_user_inatomic(dst,
87637 - (__force const void __user *)src, size);
87638 + (const void __force_user *)src, size);
87639 pagefault_enable();
87640 set_fs(old_fs);
87641
87642 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
87643
87644 set_fs(KERNEL_DS);
87645 pagefault_disable();
87646 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
87647 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
87648 pagefault_enable();
87649 set_fs(old_fs);
87650
87651 diff --git a/mm/madvise.c b/mm/madvise.c
87652 index 7055883..aafb1ed 100644
87653 --- a/mm/madvise.c
87654 +++ b/mm/madvise.c
87655 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
87656 pgoff_t pgoff;
87657 unsigned long new_flags = vma->vm_flags;
87658
87659 +#ifdef CONFIG_PAX_SEGMEXEC
87660 + struct vm_area_struct *vma_m;
87661 +#endif
87662 +
87663 switch (behavior) {
87664 case MADV_NORMAL:
87665 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
87666 @@ -126,6 +130,13 @@ success:
87667 /*
87668 * vm_flags is protected by the mmap_sem held in write mode.
87669 */
87670 +
87671 +#ifdef CONFIG_PAX_SEGMEXEC
87672 + vma_m = pax_find_mirror_vma(vma);
87673 + if (vma_m)
87674 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
87675 +#endif
87676 +
87677 vma->vm_flags = new_flags;
87678
87679 out:
87680 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
87681 struct vm_area_struct ** prev,
87682 unsigned long start, unsigned long end)
87683 {
87684 +
87685 +#ifdef CONFIG_PAX_SEGMEXEC
87686 + struct vm_area_struct *vma_m;
87687 +#endif
87688 +
87689 *prev = vma;
87690 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
87691 return -EINVAL;
87692 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
87693 zap_page_range(vma, start, end - start, &details);
87694 } else
87695 zap_page_range(vma, start, end - start, NULL);
87696 +
87697 +#ifdef CONFIG_PAX_SEGMEXEC
87698 + vma_m = pax_find_mirror_vma(vma);
87699 + if (vma_m) {
87700 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
87701 + struct zap_details details = {
87702 + .nonlinear_vma = vma_m,
87703 + .last_index = ULONG_MAX,
87704 + };
87705 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
87706 + } else
87707 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
87708 + }
87709 +#endif
87710 +
87711 return 0;
87712 }
87713
87714 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
87715 if (end < start)
87716 return error;
87717
87718 +#ifdef CONFIG_PAX_SEGMEXEC
87719 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87720 + if (end > SEGMEXEC_TASK_SIZE)
87721 + return error;
87722 + } else
87723 +#endif
87724 +
87725 + if (end > TASK_SIZE)
87726 + return error;
87727 +
87728 error = 0;
87729 if (end == start)
87730 return error;
87731 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
87732 index ceb0c7f..b2b8e94 100644
87733 --- a/mm/memory-failure.c
87734 +++ b/mm/memory-failure.c
87735 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
87736
87737 int sysctl_memory_failure_recovery __read_mostly = 1;
87738
87739 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87740 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87741
87742 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
87743
87744 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
87745 pfn, t->comm, t->pid);
87746 si.si_signo = SIGBUS;
87747 si.si_errno = 0;
87748 - si.si_addr = (void *)addr;
87749 + si.si_addr = (void __user *)addr;
87750 #ifdef __ARCH_SI_TRAPNO
87751 si.si_trapno = trapno;
87752 #endif
87753 @@ -760,7 +760,7 @@ static struct page_state {
87754 unsigned long res;
87755 char *msg;
87756 int (*action)(struct page *p, unsigned long pfn);
87757 -} error_states[] = {
87758 +} __do_const error_states[] = {
87759 { reserved, reserved, "reserved kernel", me_kernel },
87760 /*
87761 * free pages are specially detected outside this table:
87762 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87763 nr_pages = 1 << compound_order(hpage);
87764 else /* normal page or thp */
87765 nr_pages = 1;
87766 - atomic_long_add(nr_pages, &num_poisoned_pages);
87767 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
87768
87769 /*
87770 * We need/can do nothing about count=0 pages.
87771 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87772 if (!PageHWPoison(hpage)
87773 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
87774 || (p != hpage && TestSetPageHWPoison(hpage))) {
87775 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87776 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87777 return 0;
87778 }
87779 set_page_hwpoison_huge_page(hpage);
87780 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87781 }
87782 if (hwpoison_filter(p)) {
87783 if (TestClearPageHWPoison(p))
87784 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87785 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87786 unlock_page(hpage);
87787 put_page(hpage);
87788 return 0;
87789 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
87790 return 0;
87791 }
87792 if (TestClearPageHWPoison(p))
87793 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87794 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87795 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
87796 return 0;
87797 }
87798 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
87799 */
87800 if (TestClearPageHWPoison(page)) {
87801 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
87802 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87803 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87804 freeit = 1;
87805 if (PageHuge(page))
87806 clear_page_hwpoison_huge_page(page);
87807 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
87808 } else {
87809 set_page_hwpoison_huge_page(hpage);
87810 dequeue_hwpoisoned_huge_page(hpage);
87811 - atomic_long_add(1 << compound_trans_order(hpage),
87812 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
87813 &num_poisoned_pages);
87814 }
87815 /* keep elevated page count for bad page */
87816 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
87817 if (PageHuge(page)) {
87818 set_page_hwpoison_huge_page(hpage);
87819 dequeue_hwpoisoned_huge_page(hpage);
87820 - atomic_long_add(1 << compound_trans_order(hpage),
87821 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
87822 &num_poisoned_pages);
87823 } else {
87824 SetPageHWPoison(page);
87825 - atomic_long_inc(&num_poisoned_pages);
87826 + atomic_long_inc_unchecked(&num_poisoned_pages);
87827 }
87828 }
87829 /* keep elevated page count for bad page */
87830 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
87831 put_page(page);
87832 pr_info("soft_offline: %#lx: invalidated\n", pfn);
87833 SetPageHWPoison(page);
87834 - atomic_long_inc(&num_poisoned_pages);
87835 + atomic_long_inc_unchecked(&num_poisoned_pages);
87836 return 0;
87837 }
87838
87839 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
87840 ret = -EIO;
87841 } else {
87842 SetPageHWPoison(page);
87843 - atomic_long_inc(&num_poisoned_pages);
87844 + atomic_long_inc_unchecked(&num_poisoned_pages);
87845 }
87846 } else {
87847 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
87848 diff --git a/mm/memory.c b/mm/memory.c
87849 index 5a35443..7c0340f 100644
87850 --- a/mm/memory.c
87851 +++ b/mm/memory.c
87852 @@ -428,6 +428,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87853 free_pte_range(tlb, pmd, addr);
87854 } while (pmd++, addr = next, addr != end);
87855
87856 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
87857 start &= PUD_MASK;
87858 if (start < floor)
87859 return;
87860 @@ -442,6 +443,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87861 pmd = pmd_offset(pud, start);
87862 pud_clear(pud);
87863 pmd_free_tlb(tlb, pmd, start);
87864 +#endif
87865 +
87866 }
87867
87868 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87869 @@ -461,6 +464,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87870 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
87871 } while (pud++, addr = next, addr != end);
87872
87873 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
87874 start &= PGDIR_MASK;
87875 if (start < floor)
87876 return;
87877 @@ -475,6 +479,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87878 pud = pud_offset(pgd, start);
87879 pgd_clear(pgd);
87880 pud_free_tlb(tlb, pud, start);
87881 +#endif
87882 +
87883 }
87884
87885 /*
87886 @@ -1644,12 +1650,6 @@ no_page_table:
87887 return page;
87888 }
87889
87890 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
87891 -{
87892 - return stack_guard_page_start(vma, addr) ||
87893 - stack_guard_page_end(vma, addr+PAGE_SIZE);
87894 -}
87895 -
87896 /**
87897 * __get_user_pages() - pin user pages in memory
87898 * @tsk: task_struct of target task
87899 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87900
87901 i = 0;
87902
87903 - do {
87904 + while (nr_pages) {
87905 struct vm_area_struct *vma;
87906
87907 - vma = find_extend_vma(mm, start);
87908 + vma = find_vma(mm, start);
87909 if (!vma && in_gate_area(mm, start)) {
87910 unsigned long pg = start & PAGE_MASK;
87911 pgd_t *pgd;
87912 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87913 goto next_page;
87914 }
87915
87916 - if (!vma ||
87917 + if (!vma || start < vma->vm_start ||
87918 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
87919 !(vm_flags & vma->vm_flags))
87920 return i ? : -EFAULT;
87921 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87922 int ret;
87923 unsigned int fault_flags = 0;
87924
87925 - /* For mlock, just skip the stack guard page. */
87926 - if (foll_flags & FOLL_MLOCK) {
87927 - if (stack_guard_page(vma, start))
87928 - goto next_page;
87929 - }
87930 if (foll_flags & FOLL_WRITE)
87931 fault_flags |= FAULT_FLAG_WRITE;
87932 if (nonblocking)
87933 @@ -1901,7 +1896,7 @@ next_page:
87934 start += page_increm * PAGE_SIZE;
87935 nr_pages -= page_increm;
87936 } while (nr_pages && start < vma->vm_end);
87937 - } while (nr_pages);
87938 + }
87939 return i;
87940 }
87941 EXPORT_SYMBOL(__get_user_pages);
87942 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
87943 page_add_file_rmap(page);
87944 set_pte_at(mm, addr, pte, mk_pte(page, prot));
87945
87946 +#ifdef CONFIG_PAX_SEGMEXEC
87947 + pax_mirror_file_pte(vma, addr, page, ptl);
87948 +#endif
87949 +
87950 retval = 0;
87951 pte_unmap_unlock(pte, ptl);
87952 return retval;
87953 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
87954 if (!page_count(page))
87955 return -EINVAL;
87956 if (!(vma->vm_flags & VM_MIXEDMAP)) {
87957 +
87958 +#ifdef CONFIG_PAX_SEGMEXEC
87959 + struct vm_area_struct *vma_m;
87960 +#endif
87961 +
87962 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
87963 BUG_ON(vma->vm_flags & VM_PFNMAP);
87964 vma->vm_flags |= VM_MIXEDMAP;
87965 +
87966 +#ifdef CONFIG_PAX_SEGMEXEC
87967 + vma_m = pax_find_mirror_vma(vma);
87968 + if (vma_m)
87969 + vma_m->vm_flags |= VM_MIXEDMAP;
87970 +#endif
87971 +
87972 }
87973 return insert_page(vma, addr, page, vma->vm_page_prot);
87974 }
87975 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87976 unsigned long pfn)
87977 {
87978 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87979 + BUG_ON(vma->vm_mirror);
87980
87981 if (addr < vma->vm_start || addr >= vma->vm_end)
87982 return -EFAULT;
87983 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87984
87985 BUG_ON(pud_huge(*pud));
87986
87987 - pmd = pmd_alloc(mm, pud, addr);
87988 + pmd = (mm == &init_mm) ?
87989 + pmd_alloc_kernel(mm, pud, addr) :
87990 + pmd_alloc(mm, pud, addr);
87991 if (!pmd)
87992 return -ENOMEM;
87993 do {
87994 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87995 unsigned long next;
87996 int err;
87997
87998 - pud = pud_alloc(mm, pgd, addr);
87999 + pud = (mm == &init_mm) ?
88000 + pud_alloc_kernel(mm, pgd, addr) :
88001 + pud_alloc(mm, pgd, addr);
88002 if (!pud)
88003 return -ENOMEM;
88004 do {
88005 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
88006 copy_user_highpage(dst, src, va, vma);
88007 }
88008
88009 +#ifdef CONFIG_PAX_SEGMEXEC
88010 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
88011 +{
88012 + struct mm_struct *mm = vma->vm_mm;
88013 + spinlock_t *ptl;
88014 + pte_t *pte, entry;
88015 +
88016 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
88017 + entry = *pte;
88018 + if (!pte_present(entry)) {
88019 + if (!pte_none(entry)) {
88020 + BUG_ON(pte_file(entry));
88021 + free_swap_and_cache(pte_to_swp_entry(entry));
88022 + pte_clear_not_present_full(mm, address, pte, 0);
88023 + }
88024 + } else {
88025 + struct page *page;
88026 +
88027 + flush_cache_page(vma, address, pte_pfn(entry));
88028 + entry = ptep_clear_flush(vma, address, pte);
88029 + BUG_ON(pte_dirty(entry));
88030 + page = vm_normal_page(vma, address, entry);
88031 + if (page) {
88032 + update_hiwater_rss(mm);
88033 + if (PageAnon(page))
88034 + dec_mm_counter_fast(mm, MM_ANONPAGES);
88035 + else
88036 + dec_mm_counter_fast(mm, MM_FILEPAGES);
88037 + page_remove_rmap(page);
88038 + page_cache_release(page);
88039 + }
88040 + }
88041 + pte_unmap_unlock(pte, ptl);
88042 +}
88043 +
88044 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
88045 + *
88046 + * the ptl of the lower mapped page is held on entry and is not released on exit
88047 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
88048 + */
88049 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88050 +{
88051 + struct mm_struct *mm = vma->vm_mm;
88052 + unsigned long address_m;
88053 + spinlock_t *ptl_m;
88054 + struct vm_area_struct *vma_m;
88055 + pmd_t *pmd_m;
88056 + pte_t *pte_m, entry_m;
88057 +
88058 + BUG_ON(!page_m || !PageAnon(page_m));
88059 +
88060 + vma_m = pax_find_mirror_vma(vma);
88061 + if (!vma_m)
88062 + return;
88063 +
88064 + BUG_ON(!PageLocked(page_m));
88065 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88066 + address_m = address + SEGMEXEC_TASK_SIZE;
88067 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88068 + pte_m = pte_offset_map(pmd_m, address_m);
88069 + ptl_m = pte_lockptr(mm, pmd_m);
88070 + if (ptl != ptl_m) {
88071 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88072 + if (!pte_none(*pte_m))
88073 + goto out;
88074 + }
88075 +
88076 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88077 + page_cache_get(page_m);
88078 + page_add_anon_rmap(page_m, vma_m, address_m);
88079 + inc_mm_counter_fast(mm, MM_ANONPAGES);
88080 + set_pte_at(mm, address_m, pte_m, entry_m);
88081 + update_mmu_cache(vma_m, address_m, pte_m);
88082 +out:
88083 + if (ptl != ptl_m)
88084 + spin_unlock(ptl_m);
88085 + pte_unmap(pte_m);
88086 + unlock_page(page_m);
88087 +}
88088 +
88089 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88090 +{
88091 + struct mm_struct *mm = vma->vm_mm;
88092 + unsigned long address_m;
88093 + spinlock_t *ptl_m;
88094 + struct vm_area_struct *vma_m;
88095 + pmd_t *pmd_m;
88096 + pte_t *pte_m, entry_m;
88097 +
88098 + BUG_ON(!page_m || PageAnon(page_m));
88099 +
88100 + vma_m = pax_find_mirror_vma(vma);
88101 + if (!vma_m)
88102 + return;
88103 +
88104 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88105 + address_m = address + SEGMEXEC_TASK_SIZE;
88106 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88107 + pte_m = pte_offset_map(pmd_m, address_m);
88108 + ptl_m = pte_lockptr(mm, pmd_m);
88109 + if (ptl != ptl_m) {
88110 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88111 + if (!pte_none(*pte_m))
88112 + goto out;
88113 + }
88114 +
88115 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88116 + page_cache_get(page_m);
88117 + page_add_file_rmap(page_m);
88118 + inc_mm_counter_fast(mm, MM_FILEPAGES);
88119 + set_pte_at(mm, address_m, pte_m, entry_m);
88120 + update_mmu_cache(vma_m, address_m, pte_m);
88121 +out:
88122 + if (ptl != ptl_m)
88123 + spin_unlock(ptl_m);
88124 + pte_unmap(pte_m);
88125 +}
88126 +
88127 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
88128 +{
88129 + struct mm_struct *mm = vma->vm_mm;
88130 + unsigned long address_m;
88131 + spinlock_t *ptl_m;
88132 + struct vm_area_struct *vma_m;
88133 + pmd_t *pmd_m;
88134 + pte_t *pte_m, entry_m;
88135 +
88136 + vma_m = pax_find_mirror_vma(vma);
88137 + if (!vma_m)
88138 + return;
88139 +
88140 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88141 + address_m = address + SEGMEXEC_TASK_SIZE;
88142 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88143 + pte_m = pte_offset_map(pmd_m, address_m);
88144 + ptl_m = pte_lockptr(mm, pmd_m);
88145 + if (ptl != ptl_m) {
88146 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88147 + if (!pte_none(*pte_m))
88148 + goto out;
88149 + }
88150 +
88151 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
88152 + set_pte_at(mm, address_m, pte_m, entry_m);
88153 +out:
88154 + if (ptl != ptl_m)
88155 + spin_unlock(ptl_m);
88156 + pte_unmap(pte_m);
88157 +}
88158 +
88159 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
88160 +{
88161 + struct page *page_m;
88162 + pte_t entry;
88163 +
88164 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
88165 + goto out;
88166 +
88167 + entry = *pte;
88168 + page_m = vm_normal_page(vma, address, entry);
88169 + if (!page_m)
88170 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
88171 + else if (PageAnon(page_m)) {
88172 + if (pax_find_mirror_vma(vma)) {
88173 + pte_unmap_unlock(pte, ptl);
88174 + lock_page(page_m);
88175 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
88176 + if (pte_same(entry, *pte))
88177 + pax_mirror_anon_pte(vma, address, page_m, ptl);
88178 + else
88179 + unlock_page(page_m);
88180 + }
88181 + } else
88182 + pax_mirror_file_pte(vma, address, page_m, ptl);
88183 +
88184 +out:
88185 + pte_unmap_unlock(pte, ptl);
88186 +}
88187 +#endif
88188 +
88189 /*
88190 * This routine handles present pages, when users try to write
88191 * to a shared page. It is done by copying the page to a new address
88192 @@ -2808,6 +3004,12 @@ gotten:
88193 */
88194 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88195 if (likely(pte_same(*page_table, orig_pte))) {
88196 +
88197 +#ifdef CONFIG_PAX_SEGMEXEC
88198 + if (pax_find_mirror_vma(vma))
88199 + BUG_ON(!trylock_page(new_page));
88200 +#endif
88201 +
88202 if (old_page) {
88203 if (!PageAnon(old_page)) {
88204 dec_mm_counter_fast(mm, MM_FILEPAGES);
88205 @@ -2859,6 +3061,10 @@ gotten:
88206 page_remove_rmap(old_page);
88207 }
88208
88209 +#ifdef CONFIG_PAX_SEGMEXEC
88210 + pax_mirror_anon_pte(vma, address, new_page, ptl);
88211 +#endif
88212 +
88213 /* Free the old page.. */
88214 new_page = old_page;
88215 ret |= VM_FAULT_WRITE;
88216 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88217 swap_free(entry);
88218 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
88219 try_to_free_swap(page);
88220 +
88221 +#ifdef CONFIG_PAX_SEGMEXEC
88222 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
88223 +#endif
88224 +
88225 unlock_page(page);
88226 if (page != swapcache) {
88227 /*
88228 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88229
88230 /* No need to invalidate - it was non-present before */
88231 update_mmu_cache(vma, address, page_table);
88232 +
88233 +#ifdef CONFIG_PAX_SEGMEXEC
88234 + pax_mirror_anon_pte(vma, address, page, ptl);
88235 +#endif
88236 +
88237 unlock:
88238 pte_unmap_unlock(page_table, ptl);
88239 out:
88240 @@ -3176,40 +3392,6 @@ out_release:
88241 }
88242
88243 /*
88244 - * This is like a special single-page "expand_{down|up}wards()",
88245 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
88246 - * doesn't hit another vma.
88247 - */
88248 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
88249 -{
88250 - address &= PAGE_MASK;
88251 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
88252 - struct vm_area_struct *prev = vma->vm_prev;
88253 -
88254 - /*
88255 - * Is there a mapping abutting this one below?
88256 - *
88257 - * That's only ok if it's the same stack mapping
88258 - * that has gotten split..
88259 - */
88260 - if (prev && prev->vm_end == address)
88261 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
88262 -
88263 - expand_downwards(vma, address - PAGE_SIZE);
88264 - }
88265 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
88266 - struct vm_area_struct *next = vma->vm_next;
88267 -
88268 - /* As VM_GROWSDOWN but s/below/above/ */
88269 - if (next && next->vm_start == address + PAGE_SIZE)
88270 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
88271 -
88272 - expand_upwards(vma, address + PAGE_SIZE);
88273 - }
88274 - return 0;
88275 -}
88276 -
88277 -/*
88278 * We enter with non-exclusive mmap_sem (to exclude vma changes,
88279 * but allow concurrent faults), and pte mapped but not yet locked.
88280 * We return with mmap_sem still held, but pte unmapped and unlocked.
88281 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88282 unsigned long address, pte_t *page_table, pmd_t *pmd,
88283 unsigned int flags)
88284 {
88285 - struct page *page;
88286 + struct page *page = NULL;
88287 spinlock_t *ptl;
88288 pte_t entry;
88289
88290 - pte_unmap(page_table);
88291 -
88292 - /* Check if we need to add a guard page to the stack */
88293 - if (check_stack_guard_page(vma, address) < 0)
88294 - return VM_FAULT_SIGBUS;
88295 -
88296 - /* Use the zero-page for reads */
88297 if (!(flags & FAULT_FLAG_WRITE)) {
88298 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
88299 vma->vm_page_prot));
88300 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88301 + ptl = pte_lockptr(mm, pmd);
88302 + spin_lock(ptl);
88303 if (!pte_none(*page_table))
88304 goto unlock;
88305 goto setpte;
88306 }
88307
88308 /* Allocate our own private page. */
88309 + pte_unmap(page_table);
88310 +
88311 if (unlikely(anon_vma_prepare(vma)))
88312 goto oom;
88313 page = alloc_zeroed_user_highpage_movable(vma, address);
88314 @@ -3262,6 +3440,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88315 if (!pte_none(*page_table))
88316 goto release;
88317
88318 +#ifdef CONFIG_PAX_SEGMEXEC
88319 + if (pax_find_mirror_vma(vma))
88320 + BUG_ON(!trylock_page(page));
88321 +#endif
88322 +
88323 inc_mm_counter_fast(mm, MM_ANONPAGES);
88324 page_add_new_anon_rmap(page, vma, address);
88325 setpte:
88326 @@ -3269,6 +3452,12 @@ setpte:
88327
88328 /* No need to invalidate - it was non-present before */
88329 update_mmu_cache(vma, address, page_table);
88330 +
88331 +#ifdef CONFIG_PAX_SEGMEXEC
88332 + if (page)
88333 + pax_mirror_anon_pte(vma, address, page, ptl);
88334 +#endif
88335 +
88336 unlock:
88337 pte_unmap_unlock(page_table, ptl);
88338 return 0;
88339 @@ -3412,6 +3601,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88340 */
88341 /* Only go through if we didn't race with anybody else... */
88342 if (likely(pte_same(*page_table, orig_pte))) {
88343 +
88344 +#ifdef CONFIG_PAX_SEGMEXEC
88345 + if (anon && pax_find_mirror_vma(vma))
88346 + BUG_ON(!trylock_page(page));
88347 +#endif
88348 +
88349 flush_icache_page(vma, page);
88350 entry = mk_pte(page, vma->vm_page_prot);
88351 if (flags & FAULT_FLAG_WRITE)
88352 @@ -3431,6 +3626,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88353
88354 /* no need to invalidate: a not-present page won't be cached */
88355 update_mmu_cache(vma, address, page_table);
88356 +
88357 +#ifdef CONFIG_PAX_SEGMEXEC
88358 + if (anon)
88359 + pax_mirror_anon_pte(vma, address, page, ptl);
88360 + else
88361 + pax_mirror_file_pte(vma, address, page, ptl);
88362 +#endif
88363 +
88364 } else {
88365 if (cow_page)
88366 mem_cgroup_uncharge_page(cow_page);
88367 @@ -3752,6 +3955,12 @@ int handle_pte_fault(struct mm_struct *mm,
88368 if (flags & FAULT_FLAG_WRITE)
88369 flush_tlb_fix_spurious_fault(vma, address);
88370 }
88371 +
88372 +#ifdef CONFIG_PAX_SEGMEXEC
88373 + pax_mirror_pte(vma, address, pte, pmd, ptl);
88374 + return 0;
88375 +#endif
88376 +
88377 unlock:
88378 pte_unmap_unlock(pte, ptl);
88379 return 0;
88380 @@ -3768,6 +3977,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88381 pmd_t *pmd;
88382 pte_t *pte;
88383
88384 +#ifdef CONFIG_PAX_SEGMEXEC
88385 + struct vm_area_struct *vma_m;
88386 +#endif
88387 +
88388 __set_current_state(TASK_RUNNING);
88389
88390 count_vm_event(PGFAULT);
88391 @@ -3779,6 +3992,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88392 if (unlikely(is_vm_hugetlb_page(vma)))
88393 return hugetlb_fault(mm, vma, address, flags);
88394
88395 +#ifdef CONFIG_PAX_SEGMEXEC
88396 + vma_m = pax_find_mirror_vma(vma);
88397 + if (vma_m) {
88398 + unsigned long address_m;
88399 + pgd_t *pgd_m;
88400 + pud_t *pud_m;
88401 + pmd_t *pmd_m;
88402 +
88403 + if (vma->vm_start > vma_m->vm_start) {
88404 + address_m = address;
88405 + address -= SEGMEXEC_TASK_SIZE;
88406 + vma = vma_m;
88407 + } else
88408 + address_m = address + SEGMEXEC_TASK_SIZE;
88409 +
88410 + pgd_m = pgd_offset(mm, address_m);
88411 + pud_m = pud_alloc(mm, pgd_m, address_m);
88412 + if (!pud_m)
88413 + return VM_FAULT_OOM;
88414 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88415 + if (!pmd_m)
88416 + return VM_FAULT_OOM;
88417 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88418 + return VM_FAULT_OOM;
88419 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88420 + }
88421 +#endif
88422 +
88423 retry:
88424 pgd = pgd_offset(mm, address);
88425 pud = pud_alloc(mm, pgd, address);
88426 @@ -3877,6 +4118,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88427 spin_unlock(&mm->page_table_lock);
88428 return 0;
88429 }
88430 +
88431 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88432 +{
88433 + pud_t *new = pud_alloc_one(mm, address);
88434 + if (!new)
88435 + return -ENOMEM;
88436 +
88437 + smp_wmb(); /* See comment in __pte_alloc */
88438 +
88439 + spin_lock(&mm->page_table_lock);
88440 + if (pgd_present(*pgd)) /* Another has populated it */
88441 + pud_free(mm, new);
88442 + else
88443 + pgd_populate_kernel(mm, pgd, new);
88444 + spin_unlock(&mm->page_table_lock);
88445 + return 0;
88446 +}
88447 #endif /* __PAGETABLE_PUD_FOLDED */
88448
88449 #ifndef __PAGETABLE_PMD_FOLDED
88450 @@ -3907,6 +4165,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88451 spin_unlock(&mm->page_table_lock);
88452 return 0;
88453 }
88454 +
88455 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88456 +{
88457 + pmd_t *new = pmd_alloc_one(mm, address);
88458 + if (!new)
88459 + return -ENOMEM;
88460 +
88461 + smp_wmb(); /* See comment in __pte_alloc */
88462 +
88463 + spin_lock(&mm->page_table_lock);
88464 +#ifndef __ARCH_HAS_4LEVEL_HACK
88465 + if (pud_present(*pud)) /* Another has populated it */
88466 + pmd_free(mm, new);
88467 + else
88468 + pud_populate_kernel(mm, pud, new);
88469 +#else
88470 + if (pgd_present(*pud)) /* Another has populated it */
88471 + pmd_free(mm, new);
88472 + else
88473 + pgd_populate_kernel(mm, pud, new);
88474 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88475 + spin_unlock(&mm->page_table_lock);
88476 + return 0;
88477 +}
88478 #endif /* __PAGETABLE_PMD_FOLDED */
88479
88480 #if !defined(__HAVE_ARCH_GATE_AREA)
88481 @@ -3920,7 +4202,7 @@ static int __init gate_vma_init(void)
88482 gate_vma.vm_start = FIXADDR_USER_START;
88483 gate_vma.vm_end = FIXADDR_USER_END;
88484 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88485 - gate_vma.vm_page_prot = __P101;
88486 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88487
88488 return 0;
88489 }
88490 @@ -4054,8 +4336,8 @@ out:
88491 return ret;
88492 }
88493
88494 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88495 - void *buf, int len, int write)
88496 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88497 + void *buf, size_t len, int write)
88498 {
88499 resource_size_t phys_addr;
88500 unsigned long prot = 0;
88501 @@ -4080,8 +4362,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88502 * Access another process' address space as given in mm. If non-NULL, use the
88503 * given task for page fault accounting.
88504 */
88505 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88506 - unsigned long addr, void *buf, int len, int write)
88507 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88508 + unsigned long addr, void *buf, size_t len, int write)
88509 {
88510 struct vm_area_struct *vma;
88511 void *old_buf = buf;
88512 @@ -4089,7 +4371,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88513 down_read(&mm->mmap_sem);
88514 /* ignore errors, just check how much was successfully transferred */
88515 while (len) {
88516 - int bytes, ret, offset;
88517 + ssize_t bytes, ret, offset;
88518 void *maddr;
88519 struct page *page = NULL;
88520
88521 @@ -4148,8 +4430,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88522 *
88523 * The caller must hold a reference on @mm.
88524 */
88525 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88526 - void *buf, int len, int write)
88527 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88528 + void *buf, size_t len, int write)
88529 {
88530 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88531 }
88532 @@ -4159,11 +4441,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88533 * Source/target buffer must be kernel space,
88534 * Do not walk the page table directly, use get_user_pages
88535 */
88536 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88537 - void *buf, int len, int write)
88538 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88539 + void *buf, size_t len, int write)
88540 {
88541 struct mm_struct *mm;
88542 - int ret;
88543 + ssize_t ret;
88544
88545 mm = get_task_mm(tsk);
88546 if (!mm)
88547 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88548 index 4baf12e..5497066 100644
88549 --- a/mm/mempolicy.c
88550 +++ b/mm/mempolicy.c
88551 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88552 unsigned long vmstart;
88553 unsigned long vmend;
88554
88555 +#ifdef CONFIG_PAX_SEGMEXEC
88556 + struct vm_area_struct *vma_m;
88557 +#endif
88558 +
88559 vma = find_vma(mm, start);
88560 if (!vma || vma->vm_start > start)
88561 return -EFAULT;
88562 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88563 err = vma_replace_policy(vma, new_pol);
88564 if (err)
88565 goto out;
88566 +
88567 +#ifdef CONFIG_PAX_SEGMEXEC
88568 + vma_m = pax_find_mirror_vma(vma);
88569 + if (vma_m) {
88570 + err = vma_replace_policy(vma_m, new_pol);
88571 + if (err)
88572 + goto out;
88573 + }
88574 +#endif
88575 +
88576 }
88577
88578 out:
88579 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88580
88581 if (end < start)
88582 return -EINVAL;
88583 +
88584 +#ifdef CONFIG_PAX_SEGMEXEC
88585 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88586 + if (end > SEGMEXEC_TASK_SIZE)
88587 + return -EINVAL;
88588 + } else
88589 +#endif
88590 +
88591 + if (end > TASK_SIZE)
88592 + return -EINVAL;
88593 +
88594 if (end == start)
88595 return 0;
88596
88597 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88598 */
88599 tcred = __task_cred(task);
88600 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88601 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88602 - !capable(CAP_SYS_NICE)) {
88603 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88604 rcu_read_unlock();
88605 err = -EPERM;
88606 goto out_put;
88607 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88608 goto out;
88609 }
88610
88611 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
88612 + if (mm != current->mm &&
88613 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
88614 + mmput(mm);
88615 + err = -EPERM;
88616 + goto out;
88617 + }
88618 +#endif
88619 +
88620 err = do_migrate_pages(mm, old, new,
88621 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
88622
88623 diff --git a/mm/migrate.c b/mm/migrate.c
88624 index 6f0c244..6d1ae32 100644
88625 --- a/mm/migrate.c
88626 +++ b/mm/migrate.c
88627 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
88628 */
88629 tcred = __task_cred(task);
88630 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88631 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88632 - !capable(CAP_SYS_NICE)) {
88633 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88634 rcu_read_unlock();
88635 err = -EPERM;
88636 goto out;
88637 diff --git a/mm/mlock.c b/mm/mlock.c
88638 index 79b7cf7..9944291 100644
88639 --- a/mm/mlock.c
88640 +++ b/mm/mlock.c
88641 @@ -13,6 +13,7 @@
88642 #include <linux/pagemap.h>
88643 #include <linux/mempolicy.h>
88644 #include <linux/syscalls.h>
88645 +#include <linux/security.h>
88646 #include <linux/sched.h>
88647 #include <linux/export.h>
88648 #include <linux/rmap.h>
88649 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
88650 {
88651 unsigned long nstart, end, tmp;
88652 struct vm_area_struct * vma, * prev;
88653 - int error;
88654 + int error = 0;
88655
88656 VM_BUG_ON(start & ~PAGE_MASK);
88657 VM_BUG_ON(len != PAGE_ALIGN(len));
88658 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
88659 return -EINVAL;
88660 if (end == start)
88661 return 0;
88662 + if (end > TASK_SIZE)
88663 + return -EINVAL;
88664 +
88665 vma = find_vma(current->mm, start);
88666 if (!vma || vma->vm_start > start)
88667 return -ENOMEM;
88668 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
88669 for (nstart = start ; ; ) {
88670 vm_flags_t newflags;
88671
88672 +#ifdef CONFIG_PAX_SEGMEXEC
88673 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88674 + break;
88675 +#endif
88676 +
88677 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
88678
88679 newflags = vma->vm_flags & ~VM_LOCKED;
88680 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
88681 lock_limit >>= PAGE_SHIFT;
88682
88683 /* check against resource limits */
88684 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
88685 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
88686 error = do_mlock(start, len, 1);
88687 up_write(&current->mm->mmap_sem);
88688 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
88689 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
88690 vm_flags_t newflags;
88691
88692 +#ifdef CONFIG_PAX_SEGMEXEC
88693 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88694 + break;
88695 +#endif
88696 +
88697 newflags = vma->vm_flags & ~VM_LOCKED;
88698 if (flags & MCL_CURRENT)
88699 newflags |= VM_LOCKED;
88700 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
88701 lock_limit >>= PAGE_SHIFT;
88702
88703 ret = -ENOMEM;
88704 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
88705 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
88706 capable(CAP_IPC_LOCK))
88707 ret = do_mlockall(flags);
88708 diff --git a/mm/mmap.c b/mm/mmap.c
88709 index 8d25fdc..bfb7626 100644
88710 --- a/mm/mmap.c
88711 +++ b/mm/mmap.c
88712 @@ -36,6 +36,7 @@
88713 #include <linux/sched/sysctl.h>
88714 #include <linux/notifier.h>
88715 #include <linux/memory.h>
88716 +#include <linux/random.h>
88717
88718 #include <asm/uaccess.h>
88719 #include <asm/cacheflush.h>
88720 @@ -52,6 +53,16 @@
88721 #define arch_rebalance_pgtables(addr, len) (addr)
88722 #endif
88723
88724 +static inline void verify_mm_writelocked(struct mm_struct *mm)
88725 +{
88726 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
88727 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88728 + up_read(&mm->mmap_sem);
88729 + BUG();
88730 + }
88731 +#endif
88732 +}
88733 +
88734 static void unmap_region(struct mm_struct *mm,
88735 struct vm_area_struct *vma, struct vm_area_struct *prev,
88736 unsigned long start, unsigned long end);
88737 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
88738 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
88739 *
88740 */
88741 -pgprot_t protection_map[16] = {
88742 +pgprot_t protection_map[16] __read_only = {
88743 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
88744 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
88745 };
88746
88747 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
88748 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
88749 {
88750 - return __pgprot(pgprot_val(protection_map[vm_flags &
88751 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
88752 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
88753 pgprot_val(arch_vm_get_page_prot(vm_flags)));
88754 +
88755 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88756 + if (!(__supported_pte_mask & _PAGE_NX) &&
88757 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
88758 + (vm_flags & (VM_READ | VM_WRITE)))
88759 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
88760 +#endif
88761 +
88762 + return prot;
88763 }
88764 EXPORT_SYMBOL(vm_get_page_prot);
88765
88766 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
88767 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
88768 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88769 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88770 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
88771 /*
88772 * Make sure vm_committed_as in one cacheline and not cacheline shared with
88773 * other variables. It can be updated by several CPUs frequently.
88774 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
88775 struct vm_area_struct *next = vma->vm_next;
88776
88777 might_sleep();
88778 + BUG_ON(vma->vm_mirror);
88779 if (vma->vm_ops && vma->vm_ops->close)
88780 vma->vm_ops->close(vma);
88781 if (vma->vm_file)
88782 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
88783 * not page aligned -Ram Gupta
88784 */
88785 rlim = rlimit(RLIMIT_DATA);
88786 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
88787 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
88788 (mm->end_data - mm->start_data) > rlim)
88789 goto out;
88790 @@ -933,6 +956,12 @@ static int
88791 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
88792 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88793 {
88794 +
88795 +#ifdef CONFIG_PAX_SEGMEXEC
88796 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
88797 + return 0;
88798 +#endif
88799 +
88800 if (is_mergeable_vma(vma, file, vm_flags) &&
88801 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88802 if (vma->vm_pgoff == vm_pgoff)
88803 @@ -952,6 +981,12 @@ static int
88804 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88805 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88806 {
88807 +
88808 +#ifdef CONFIG_PAX_SEGMEXEC
88809 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
88810 + return 0;
88811 +#endif
88812 +
88813 if (is_mergeable_vma(vma, file, vm_flags) &&
88814 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88815 pgoff_t vm_pglen;
88816 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88817 struct vm_area_struct *vma_merge(struct mm_struct *mm,
88818 struct vm_area_struct *prev, unsigned long addr,
88819 unsigned long end, unsigned long vm_flags,
88820 - struct anon_vma *anon_vma, struct file *file,
88821 + struct anon_vma *anon_vma, struct file *file,
88822 pgoff_t pgoff, struct mempolicy *policy)
88823 {
88824 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
88825 struct vm_area_struct *area, *next;
88826 int err;
88827
88828 +#ifdef CONFIG_PAX_SEGMEXEC
88829 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
88830 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
88831 +
88832 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
88833 +#endif
88834 +
88835 /*
88836 * We later require that vma->vm_flags == vm_flags,
88837 * so this tests vma->vm_flags & VM_SPECIAL, too.
88838 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88839 if (next && next->vm_end == end) /* cases 6, 7, 8 */
88840 next = next->vm_next;
88841
88842 +#ifdef CONFIG_PAX_SEGMEXEC
88843 + if (prev)
88844 + prev_m = pax_find_mirror_vma(prev);
88845 + if (area)
88846 + area_m = pax_find_mirror_vma(area);
88847 + if (next)
88848 + next_m = pax_find_mirror_vma(next);
88849 +#endif
88850 +
88851 /*
88852 * Can it merge with the predecessor?
88853 */
88854 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88855 /* cases 1, 6 */
88856 err = vma_adjust(prev, prev->vm_start,
88857 next->vm_end, prev->vm_pgoff, NULL);
88858 - } else /* cases 2, 5, 7 */
88859 +
88860 +#ifdef CONFIG_PAX_SEGMEXEC
88861 + if (!err && prev_m)
88862 + err = vma_adjust(prev_m, prev_m->vm_start,
88863 + next_m->vm_end, prev_m->vm_pgoff, NULL);
88864 +#endif
88865 +
88866 + } else { /* cases 2, 5, 7 */
88867 err = vma_adjust(prev, prev->vm_start,
88868 end, prev->vm_pgoff, NULL);
88869 +
88870 +#ifdef CONFIG_PAX_SEGMEXEC
88871 + if (!err && prev_m)
88872 + err = vma_adjust(prev_m, prev_m->vm_start,
88873 + end_m, prev_m->vm_pgoff, NULL);
88874 +#endif
88875 +
88876 + }
88877 if (err)
88878 return NULL;
88879 khugepaged_enter_vma_merge(prev);
88880 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88881 mpol_equal(policy, vma_policy(next)) &&
88882 can_vma_merge_before(next, vm_flags,
88883 anon_vma, file, pgoff+pglen)) {
88884 - if (prev && addr < prev->vm_end) /* case 4 */
88885 + if (prev && addr < prev->vm_end) { /* case 4 */
88886 err = vma_adjust(prev, prev->vm_start,
88887 addr, prev->vm_pgoff, NULL);
88888 - else /* cases 3, 8 */
88889 +
88890 +#ifdef CONFIG_PAX_SEGMEXEC
88891 + if (!err && prev_m)
88892 + err = vma_adjust(prev_m, prev_m->vm_start,
88893 + addr_m, prev_m->vm_pgoff, NULL);
88894 +#endif
88895 +
88896 + } else { /* cases 3, 8 */
88897 err = vma_adjust(area, addr, next->vm_end,
88898 next->vm_pgoff - pglen, NULL);
88899 +
88900 +#ifdef CONFIG_PAX_SEGMEXEC
88901 + if (!err && area_m)
88902 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
88903 + next_m->vm_pgoff - pglen, NULL);
88904 +#endif
88905 +
88906 + }
88907 if (err)
88908 return NULL;
88909 khugepaged_enter_vma_merge(area);
88910 @@ -1165,8 +1246,10 @@ none:
88911 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88912 struct file *file, long pages)
88913 {
88914 - const unsigned long stack_flags
88915 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
88916 +
88917 +#ifdef CONFIG_PAX_RANDMMAP
88918 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88919 +#endif
88920
88921 mm->total_vm += pages;
88922
88923 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88924 mm->shared_vm += pages;
88925 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
88926 mm->exec_vm += pages;
88927 - } else if (flags & stack_flags)
88928 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
88929 mm->stack_vm += pages;
88930 }
88931 #endif /* CONFIG_PROC_FS */
88932 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88933 * (the exception is when the underlying filesystem is noexec
88934 * mounted, in which case we dont add PROT_EXEC.)
88935 */
88936 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88937 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88938 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
88939 prot |= PROT_EXEC;
88940
88941 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88942 /* Obtain the address to map to. we verify (or select) it and ensure
88943 * that it represents a valid section of the address space.
88944 */
88945 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
88946 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
88947 if (addr & ~PAGE_MASK)
88948 return addr;
88949
88950 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88951 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
88952 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
88953
88954 +#ifdef CONFIG_PAX_MPROTECT
88955 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88956 +
88957 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
88958 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
88959 + mm->binfmt->handle_mmap)
88960 + mm->binfmt->handle_mmap(file);
88961 +#endif
88962 +
88963 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88964 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
88965 + gr_log_rwxmmap(file);
88966 +
88967 +#ifdef CONFIG_PAX_EMUPLT
88968 + vm_flags &= ~VM_EXEC;
88969 +#else
88970 + return -EPERM;
88971 +#endif
88972 +
88973 + }
88974 +
88975 + if (!(vm_flags & VM_EXEC))
88976 + vm_flags &= ~VM_MAYEXEC;
88977 +#else
88978 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88979 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88980 +#endif
88981 + else
88982 + vm_flags &= ~VM_MAYWRITE;
88983 + }
88984 +#endif
88985 +
88986 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88987 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88988 + vm_flags &= ~VM_PAGEEXEC;
88989 +#endif
88990 +
88991 if (flags & MAP_LOCKED)
88992 if (!can_do_mlock())
88993 return -EPERM;
88994 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88995 locked += mm->locked_vm;
88996 lock_limit = rlimit(RLIMIT_MEMLOCK);
88997 lock_limit >>= PAGE_SHIFT;
88998 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88999 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
89000 return -EAGAIN;
89001 }
89002 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89003 vm_flags |= VM_NORESERVE;
89004 }
89005
89006 + if (!gr_acl_handle_mmap(file, prot))
89007 + return -EACCES;
89008 +
89009 addr = mmap_region(file, addr, len, vm_flags, pgoff);
89010 if (!IS_ERR_VALUE(addr) &&
89011 ((vm_flags & VM_LOCKED) ||
89012 @@ -1432,7 +1556,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
89013 vm_flags_t vm_flags = vma->vm_flags;
89014
89015 /* If it was private or non-writable, the write bit is already clear */
89016 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
89017 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
89018 return 0;
89019
89020 /* The backer wishes to know when pages are first written to? */
89021 @@ -1480,7 +1604,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89022 unsigned long charged = 0;
89023 struct inode *inode = file ? file_inode(file) : NULL;
89024
89025 +#ifdef CONFIG_PAX_SEGMEXEC
89026 + struct vm_area_struct *vma_m = NULL;
89027 +#endif
89028 +
89029 + /*
89030 + * mm->mmap_sem is required to protect against another thread
89031 + * changing the mappings in case we sleep.
89032 + */
89033 + verify_mm_writelocked(mm);
89034 +
89035 /* Check against address space limit. */
89036 +
89037 +#ifdef CONFIG_PAX_RANDMMAP
89038 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89039 +#endif
89040 +
89041 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
89042 unsigned long nr_pages;
89043
89044 @@ -1499,11 +1638,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89045
89046 /* Clear old maps */
89047 error = -ENOMEM;
89048 -munmap_back:
89049 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89050 if (do_munmap(mm, addr, len))
89051 return -ENOMEM;
89052 - goto munmap_back;
89053 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89054 }
89055
89056 /*
89057 @@ -1534,6 +1672,16 @@ munmap_back:
89058 goto unacct_error;
89059 }
89060
89061 +#ifdef CONFIG_PAX_SEGMEXEC
89062 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
89063 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89064 + if (!vma_m) {
89065 + error = -ENOMEM;
89066 + goto free_vma;
89067 + }
89068 + }
89069 +#endif
89070 +
89071 vma->vm_mm = mm;
89072 vma->vm_start = addr;
89073 vma->vm_end = addr + len;
89074 @@ -1558,6 +1706,13 @@ munmap_back:
89075 if (error)
89076 goto unmap_and_free_vma;
89077
89078 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89079 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
89080 + vma->vm_flags |= VM_PAGEEXEC;
89081 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89082 + }
89083 +#endif
89084 +
89085 /* Can addr have changed??
89086 *
89087 * Answer: Yes, several device drivers can do it in their
89088 @@ -1596,6 +1751,11 @@ munmap_back:
89089 vma_link(mm, vma, prev, rb_link, rb_parent);
89090 file = vma->vm_file;
89091
89092 +#ifdef CONFIG_PAX_SEGMEXEC
89093 + if (vma_m)
89094 + BUG_ON(pax_mirror_vma(vma_m, vma));
89095 +#endif
89096 +
89097 /* Once vma denies write, undo our temporary denial count */
89098 if (correct_wcount)
89099 atomic_inc(&inode->i_writecount);
89100 @@ -1603,6 +1763,7 @@ out:
89101 perf_event_mmap(vma);
89102
89103 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
89104 + track_exec_limit(mm, addr, addr + len, vm_flags);
89105 if (vm_flags & VM_LOCKED) {
89106 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
89107 vma == get_gate_vma(current->mm)))
89108 @@ -1626,6 +1787,12 @@ unmap_and_free_vma:
89109 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
89110 charged = 0;
89111 free_vma:
89112 +
89113 +#ifdef CONFIG_PAX_SEGMEXEC
89114 + if (vma_m)
89115 + kmem_cache_free(vm_area_cachep, vma_m);
89116 +#endif
89117 +
89118 kmem_cache_free(vm_area_cachep, vma);
89119 unacct_error:
89120 if (charged)
89121 @@ -1633,7 +1800,63 @@ unacct_error:
89122 return error;
89123 }
89124
89125 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89126 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
89127 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
89128 +{
89129 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
89130 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
89131 +
89132 + return 0;
89133 +}
89134 +#endif
89135 +
89136 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
89137 +{
89138 + if (!vma) {
89139 +#ifdef CONFIG_STACK_GROWSUP
89140 + if (addr > sysctl_heap_stack_gap)
89141 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
89142 + else
89143 + vma = find_vma(current->mm, 0);
89144 + if (vma && (vma->vm_flags & VM_GROWSUP))
89145 + return false;
89146 +#endif
89147 + return true;
89148 + }
89149 +
89150 + if (addr + len > vma->vm_start)
89151 + return false;
89152 +
89153 + if (vma->vm_flags & VM_GROWSDOWN)
89154 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
89155 +#ifdef CONFIG_STACK_GROWSUP
89156 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
89157 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
89158 +#endif
89159 + else if (offset)
89160 + return offset <= vma->vm_start - addr - len;
89161 +
89162 + return true;
89163 +}
89164 +
89165 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
89166 +{
89167 + if (vma->vm_start < len)
89168 + return -ENOMEM;
89169 +
89170 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
89171 + if (offset <= vma->vm_start - len)
89172 + return vma->vm_start - len - offset;
89173 + else
89174 + return -ENOMEM;
89175 + }
89176 +
89177 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
89178 + return vma->vm_start - len - sysctl_heap_stack_gap;
89179 + return -ENOMEM;
89180 +}
89181 +
89182 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
89183 {
89184 /*
89185 * We implement the search by looking for an rbtree node that
89186 @@ -1681,11 +1904,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89187 }
89188 }
89189
89190 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
89191 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
89192 check_current:
89193 /* Check if current node has a suitable gap */
89194 if (gap_start > high_limit)
89195 return -ENOMEM;
89196 +
89197 + if (gap_end - gap_start > info->threadstack_offset)
89198 + gap_start += info->threadstack_offset;
89199 + else
89200 + gap_start = gap_end;
89201 +
89202 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89203 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89204 + gap_start += sysctl_heap_stack_gap;
89205 + else
89206 + gap_start = gap_end;
89207 + }
89208 + if (vma->vm_flags & VM_GROWSDOWN) {
89209 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89210 + gap_end -= sysctl_heap_stack_gap;
89211 + else
89212 + gap_end = gap_start;
89213 + }
89214 if (gap_end >= low_limit && gap_end - gap_start >= length)
89215 goto found;
89216
89217 @@ -1735,7 +1976,7 @@ found:
89218 return gap_start;
89219 }
89220
89221 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
89222 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
89223 {
89224 struct mm_struct *mm = current->mm;
89225 struct vm_area_struct *vma;
89226 @@ -1789,6 +2030,24 @@ check_current:
89227 gap_end = vma->vm_start;
89228 if (gap_end < low_limit)
89229 return -ENOMEM;
89230 +
89231 + if (gap_end - gap_start > info->threadstack_offset)
89232 + gap_end -= info->threadstack_offset;
89233 + else
89234 + gap_end = gap_start;
89235 +
89236 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89237 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89238 + gap_start += sysctl_heap_stack_gap;
89239 + else
89240 + gap_start = gap_end;
89241 + }
89242 + if (vma->vm_flags & VM_GROWSDOWN) {
89243 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89244 + gap_end -= sysctl_heap_stack_gap;
89245 + else
89246 + gap_end = gap_start;
89247 + }
89248 if (gap_start <= high_limit && gap_end - gap_start >= length)
89249 goto found;
89250
89251 @@ -1852,6 +2111,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89252 struct mm_struct *mm = current->mm;
89253 struct vm_area_struct *vma;
89254 struct vm_unmapped_area_info info;
89255 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89256
89257 if (len > TASK_SIZE)
89258 return -ENOMEM;
89259 @@ -1859,29 +2119,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89260 if (flags & MAP_FIXED)
89261 return addr;
89262
89263 +#ifdef CONFIG_PAX_RANDMMAP
89264 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89265 +#endif
89266 +
89267 if (addr) {
89268 addr = PAGE_ALIGN(addr);
89269 vma = find_vma(mm, addr);
89270 - if (TASK_SIZE - len >= addr &&
89271 - (!vma || addr + len <= vma->vm_start))
89272 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
89273 return addr;
89274 }
89275
89276 info.flags = 0;
89277 info.length = len;
89278 info.low_limit = TASK_UNMAPPED_BASE;
89279 +
89280 +#ifdef CONFIG_PAX_RANDMMAP
89281 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89282 + info.low_limit += mm->delta_mmap;
89283 +#endif
89284 +
89285 info.high_limit = TASK_SIZE;
89286 info.align_mask = 0;
89287 + info.threadstack_offset = offset;
89288 return vm_unmapped_area(&info);
89289 }
89290 #endif
89291
89292 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
89293 {
89294 +
89295 +#ifdef CONFIG_PAX_SEGMEXEC
89296 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
89297 + return;
89298 +#endif
89299 +
89300 /*
89301 * Is this a new hole at the lowest possible address?
89302 */
89303 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
89304 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
89305 mm->free_area_cache = addr;
89306 }
89307
89308 @@ -1899,6 +2175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89309 struct mm_struct *mm = current->mm;
89310 unsigned long addr = addr0;
89311 struct vm_unmapped_area_info info;
89312 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89313
89314 /* requested length too big for entire address space */
89315 if (len > TASK_SIZE)
89316 @@ -1907,12 +2184,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89317 if (flags & MAP_FIXED)
89318 return addr;
89319
89320 +#ifdef CONFIG_PAX_RANDMMAP
89321 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89322 +#endif
89323 +
89324 /* requesting a specific address */
89325 if (addr) {
89326 addr = PAGE_ALIGN(addr);
89327 vma = find_vma(mm, addr);
89328 - if (TASK_SIZE - len >= addr &&
89329 - (!vma || addr + len <= vma->vm_start))
89330 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
89331 return addr;
89332 }
89333
89334 @@ -1921,6 +2201,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89335 info.low_limit = PAGE_SIZE;
89336 info.high_limit = mm->mmap_base;
89337 info.align_mask = 0;
89338 + info.threadstack_offset = offset;
89339 addr = vm_unmapped_area(&info);
89340
89341 /*
89342 @@ -1933,6 +2214,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89343 VM_BUG_ON(addr != -ENOMEM);
89344 info.flags = 0;
89345 info.low_limit = TASK_UNMAPPED_BASE;
89346 +
89347 +#ifdef CONFIG_PAX_RANDMMAP
89348 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89349 + info.low_limit += mm->delta_mmap;
89350 +#endif
89351 +
89352 info.high_limit = TASK_SIZE;
89353 addr = vm_unmapped_area(&info);
89354 }
89355 @@ -1943,6 +2230,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89356
89357 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
89358 {
89359 +
89360 +#ifdef CONFIG_PAX_SEGMEXEC
89361 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
89362 + return;
89363 +#endif
89364 +
89365 /*
89366 * Is this a new hole at the highest possible address?
89367 */
89368 @@ -1950,8 +2243,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
89369 mm->free_area_cache = addr;
89370
89371 /* dont allow allocations above current base */
89372 - if (mm->free_area_cache > mm->mmap_base)
89373 + if (mm->free_area_cache > mm->mmap_base) {
89374 mm->free_area_cache = mm->mmap_base;
89375 + mm->cached_hole_size = ~0UL;
89376 + }
89377 }
89378
89379 unsigned long
89380 @@ -2047,6 +2342,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
89381 return vma;
89382 }
89383
89384 +#ifdef CONFIG_PAX_SEGMEXEC
89385 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
89386 +{
89387 + struct vm_area_struct *vma_m;
89388 +
89389 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
89390 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
89391 + BUG_ON(vma->vm_mirror);
89392 + return NULL;
89393 + }
89394 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
89395 + vma_m = vma->vm_mirror;
89396 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
89397 + BUG_ON(vma->vm_file != vma_m->vm_file);
89398 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
89399 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
89400 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
89401 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
89402 + return vma_m;
89403 +}
89404 +#endif
89405 +
89406 /*
89407 * Verify that the stack growth is acceptable and
89408 * update accounting. This is shared with both the
89409 @@ -2063,6 +2380,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89410 return -ENOMEM;
89411
89412 /* Stack limit test */
89413 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
89414 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
89415 return -ENOMEM;
89416
89417 @@ -2073,6 +2391,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89418 locked = mm->locked_vm + grow;
89419 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
89420 limit >>= PAGE_SHIFT;
89421 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89422 if (locked > limit && !capable(CAP_IPC_LOCK))
89423 return -ENOMEM;
89424 }
89425 @@ -2102,37 +2421,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89426 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
89427 * vma is the last one with address > vma->vm_end. Have to extend vma.
89428 */
89429 +#ifndef CONFIG_IA64
89430 +static
89431 +#endif
89432 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89433 {
89434 int error;
89435 + bool locknext;
89436
89437 if (!(vma->vm_flags & VM_GROWSUP))
89438 return -EFAULT;
89439
89440 + /* Also guard against wrapping around to address 0. */
89441 + if (address < PAGE_ALIGN(address+1))
89442 + address = PAGE_ALIGN(address+1);
89443 + else
89444 + return -ENOMEM;
89445 +
89446 /*
89447 * We must make sure the anon_vma is allocated
89448 * so that the anon_vma locking is not a noop.
89449 */
89450 if (unlikely(anon_vma_prepare(vma)))
89451 return -ENOMEM;
89452 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89453 + if (locknext && anon_vma_prepare(vma->vm_next))
89454 + return -ENOMEM;
89455 vma_lock_anon_vma(vma);
89456 + if (locknext)
89457 + vma_lock_anon_vma(vma->vm_next);
89458
89459 /*
89460 * vma->vm_start/vm_end cannot change under us because the caller
89461 * is required to hold the mmap_sem in read mode. We need the
89462 - * anon_vma lock to serialize against concurrent expand_stacks.
89463 - * Also guard against wrapping around to address 0.
89464 + * anon_vma locks to serialize against concurrent expand_stacks
89465 + * and expand_upwards.
89466 */
89467 - if (address < PAGE_ALIGN(address+4))
89468 - address = PAGE_ALIGN(address+4);
89469 - else {
89470 - vma_unlock_anon_vma(vma);
89471 - return -ENOMEM;
89472 - }
89473 error = 0;
89474
89475 /* Somebody else might have raced and expanded it already */
89476 - if (address > vma->vm_end) {
89477 + 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)
89478 + error = -ENOMEM;
89479 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89480 unsigned long size, grow;
89481
89482 size = address - vma->vm_start;
89483 @@ -2167,6 +2497,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89484 }
89485 }
89486 }
89487 + if (locknext)
89488 + vma_unlock_anon_vma(vma->vm_next);
89489 vma_unlock_anon_vma(vma);
89490 khugepaged_enter_vma_merge(vma);
89491 validate_mm(vma->vm_mm);
89492 @@ -2181,6 +2513,8 @@ int expand_downwards(struct vm_area_struct *vma,
89493 unsigned long address)
89494 {
89495 int error;
89496 + bool lockprev = false;
89497 + struct vm_area_struct *prev;
89498
89499 /*
89500 * We must make sure the anon_vma is allocated
89501 @@ -2194,6 +2528,15 @@ int expand_downwards(struct vm_area_struct *vma,
89502 if (error)
89503 return error;
89504
89505 + prev = vma->vm_prev;
89506 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89507 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89508 +#endif
89509 + if (lockprev && anon_vma_prepare(prev))
89510 + return -ENOMEM;
89511 + if (lockprev)
89512 + vma_lock_anon_vma(prev);
89513 +
89514 vma_lock_anon_vma(vma);
89515
89516 /*
89517 @@ -2203,9 +2546,17 @@ int expand_downwards(struct vm_area_struct *vma,
89518 */
89519
89520 /* Somebody else might have raced and expanded it already */
89521 - if (address < vma->vm_start) {
89522 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89523 + error = -ENOMEM;
89524 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89525 unsigned long size, grow;
89526
89527 +#ifdef CONFIG_PAX_SEGMEXEC
89528 + struct vm_area_struct *vma_m;
89529 +
89530 + vma_m = pax_find_mirror_vma(vma);
89531 +#endif
89532 +
89533 size = vma->vm_end - address;
89534 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89535
89536 @@ -2230,13 +2581,27 @@ int expand_downwards(struct vm_area_struct *vma,
89537 vma->vm_pgoff -= grow;
89538 anon_vma_interval_tree_post_update_vma(vma);
89539 vma_gap_update(vma);
89540 +
89541 +#ifdef CONFIG_PAX_SEGMEXEC
89542 + if (vma_m) {
89543 + anon_vma_interval_tree_pre_update_vma(vma_m);
89544 + vma_m->vm_start -= grow << PAGE_SHIFT;
89545 + vma_m->vm_pgoff -= grow;
89546 + anon_vma_interval_tree_post_update_vma(vma_m);
89547 + vma_gap_update(vma_m);
89548 + }
89549 +#endif
89550 +
89551 spin_unlock(&vma->vm_mm->page_table_lock);
89552
89553 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89554 perf_event_mmap(vma);
89555 }
89556 }
89557 }
89558 vma_unlock_anon_vma(vma);
89559 + if (lockprev)
89560 + vma_unlock_anon_vma(prev);
89561 khugepaged_enter_vma_merge(vma);
89562 validate_mm(vma->vm_mm);
89563 return error;
89564 @@ -2334,6 +2699,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89565 do {
89566 long nrpages = vma_pages(vma);
89567
89568 +#ifdef CONFIG_PAX_SEGMEXEC
89569 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89570 + vma = remove_vma(vma);
89571 + continue;
89572 + }
89573 +#endif
89574 +
89575 if (vma->vm_flags & VM_ACCOUNT)
89576 nr_accounted += nrpages;
89577 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89578 @@ -2379,6 +2751,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89579 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89580 vma->vm_prev = NULL;
89581 do {
89582 +
89583 +#ifdef CONFIG_PAX_SEGMEXEC
89584 + if (vma->vm_mirror) {
89585 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89586 + vma->vm_mirror->vm_mirror = NULL;
89587 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89588 + vma->vm_mirror = NULL;
89589 + }
89590 +#endif
89591 +
89592 vma_rb_erase(vma, &mm->mm_rb);
89593 mm->map_count--;
89594 tail_vma = vma;
89595 @@ -2410,14 +2792,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89596 struct vm_area_struct *new;
89597 int err = -ENOMEM;
89598
89599 +#ifdef CONFIG_PAX_SEGMEXEC
89600 + struct vm_area_struct *vma_m, *new_m = NULL;
89601 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89602 +#endif
89603 +
89604 if (is_vm_hugetlb_page(vma) && (addr &
89605 ~(huge_page_mask(hstate_vma(vma)))))
89606 return -EINVAL;
89607
89608 +#ifdef CONFIG_PAX_SEGMEXEC
89609 + vma_m = pax_find_mirror_vma(vma);
89610 +#endif
89611 +
89612 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89613 if (!new)
89614 goto out_err;
89615
89616 +#ifdef CONFIG_PAX_SEGMEXEC
89617 + if (vma_m) {
89618 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89619 + if (!new_m) {
89620 + kmem_cache_free(vm_area_cachep, new);
89621 + goto out_err;
89622 + }
89623 + }
89624 +#endif
89625 +
89626 /* most fields are the same, copy all, and then fixup */
89627 *new = *vma;
89628
89629 @@ -2430,6 +2831,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89630 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
89631 }
89632
89633 +#ifdef CONFIG_PAX_SEGMEXEC
89634 + if (vma_m) {
89635 + *new_m = *vma_m;
89636 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
89637 + new_m->vm_mirror = new;
89638 + new->vm_mirror = new_m;
89639 +
89640 + if (new_below)
89641 + new_m->vm_end = addr_m;
89642 + else {
89643 + new_m->vm_start = addr_m;
89644 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
89645 + }
89646 + }
89647 +#endif
89648 +
89649 pol = mpol_dup(vma_policy(vma));
89650 if (IS_ERR(pol)) {
89651 err = PTR_ERR(pol);
89652 @@ -2452,6 +2869,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89653 else
89654 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
89655
89656 +#ifdef CONFIG_PAX_SEGMEXEC
89657 + if (!err && vma_m) {
89658 + if (anon_vma_clone(new_m, vma_m))
89659 + goto out_free_mpol;
89660 +
89661 + mpol_get(pol);
89662 + vma_set_policy(new_m, pol);
89663 +
89664 + if (new_m->vm_file)
89665 + get_file(new_m->vm_file);
89666 +
89667 + if (new_m->vm_ops && new_m->vm_ops->open)
89668 + new_m->vm_ops->open(new_m);
89669 +
89670 + if (new_below)
89671 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
89672 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
89673 + else
89674 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
89675 +
89676 + if (err) {
89677 + if (new_m->vm_ops && new_m->vm_ops->close)
89678 + new_m->vm_ops->close(new_m);
89679 + if (new_m->vm_file)
89680 + fput(new_m->vm_file);
89681 + mpol_put(pol);
89682 + }
89683 + }
89684 +#endif
89685 +
89686 /* Success. */
89687 if (!err)
89688 return 0;
89689 @@ -2461,10 +2908,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89690 new->vm_ops->close(new);
89691 if (new->vm_file)
89692 fput(new->vm_file);
89693 - unlink_anon_vmas(new);
89694 out_free_mpol:
89695 mpol_put(pol);
89696 out_free_vma:
89697 +
89698 +#ifdef CONFIG_PAX_SEGMEXEC
89699 + if (new_m) {
89700 + unlink_anon_vmas(new_m);
89701 + kmem_cache_free(vm_area_cachep, new_m);
89702 + }
89703 +#endif
89704 +
89705 + unlink_anon_vmas(new);
89706 kmem_cache_free(vm_area_cachep, new);
89707 out_err:
89708 return err;
89709 @@ -2477,6 +2932,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89710 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89711 unsigned long addr, int new_below)
89712 {
89713 +
89714 +#ifdef CONFIG_PAX_SEGMEXEC
89715 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89716 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
89717 + if (mm->map_count >= sysctl_max_map_count-1)
89718 + return -ENOMEM;
89719 + } else
89720 +#endif
89721 +
89722 if (mm->map_count >= sysctl_max_map_count)
89723 return -ENOMEM;
89724
89725 @@ -2488,11 +2952,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89726 * work. This now handles partial unmappings.
89727 * Jeremy Fitzhardinge <jeremy@goop.org>
89728 */
89729 +#ifdef CONFIG_PAX_SEGMEXEC
89730 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89731 {
89732 + int ret = __do_munmap(mm, start, len);
89733 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
89734 + return ret;
89735 +
89736 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
89737 +}
89738 +
89739 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89740 +#else
89741 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89742 +#endif
89743 +{
89744 unsigned long end;
89745 struct vm_area_struct *vma, *prev, *last;
89746
89747 + /*
89748 + * mm->mmap_sem is required to protect against another thread
89749 + * changing the mappings in case we sleep.
89750 + */
89751 + verify_mm_writelocked(mm);
89752 +
89753 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
89754 return -EINVAL;
89755
89756 @@ -2567,6 +3050,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89757 /* Fix up all other VM information */
89758 remove_vma_list(mm, vma);
89759
89760 + track_exec_limit(mm, start, end, 0UL);
89761 +
89762 return 0;
89763 }
89764
89765 @@ -2575,6 +3060,13 @@ int vm_munmap(unsigned long start, size_t len)
89766 int ret;
89767 struct mm_struct *mm = current->mm;
89768
89769 +
89770 +#ifdef CONFIG_PAX_SEGMEXEC
89771 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
89772 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
89773 + return -EINVAL;
89774 +#endif
89775 +
89776 down_write(&mm->mmap_sem);
89777 ret = do_munmap(mm, start, len);
89778 up_write(&mm->mmap_sem);
89779 @@ -2588,16 +3080,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
89780 return vm_munmap(addr, len);
89781 }
89782
89783 -static inline void verify_mm_writelocked(struct mm_struct *mm)
89784 -{
89785 -#ifdef CONFIG_DEBUG_VM
89786 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89787 - WARN_ON(1);
89788 - up_read(&mm->mmap_sem);
89789 - }
89790 -#endif
89791 -}
89792 -
89793 /*
89794 * this is really a simplified "do_mmap". it only handles
89795 * anonymous maps. eventually we may be able to do some
89796 @@ -2611,6 +3093,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89797 struct rb_node ** rb_link, * rb_parent;
89798 pgoff_t pgoff = addr >> PAGE_SHIFT;
89799 int error;
89800 + unsigned long charged;
89801
89802 len = PAGE_ALIGN(len);
89803 if (!len)
89804 @@ -2618,16 +3101,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89805
89806 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
89807
89808 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
89809 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
89810 + flags &= ~VM_EXEC;
89811 +
89812 +#ifdef CONFIG_PAX_MPROTECT
89813 + if (mm->pax_flags & MF_PAX_MPROTECT)
89814 + flags &= ~VM_MAYEXEC;
89815 +#endif
89816 +
89817 + }
89818 +#endif
89819 +
89820 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
89821 if (error & ~PAGE_MASK)
89822 return error;
89823
89824 + charged = len >> PAGE_SHIFT;
89825 +
89826 /*
89827 * mlock MCL_FUTURE?
89828 */
89829 if (mm->def_flags & VM_LOCKED) {
89830 unsigned long locked, lock_limit;
89831 - locked = len >> PAGE_SHIFT;
89832 + locked = charged;
89833 locked += mm->locked_vm;
89834 lock_limit = rlimit(RLIMIT_MEMLOCK);
89835 lock_limit >>= PAGE_SHIFT;
89836 @@ -2644,21 +3141,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89837 /*
89838 * Clear old maps. this also does some error checking for us
89839 */
89840 - munmap_back:
89841 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89842 if (do_munmap(mm, addr, len))
89843 return -ENOMEM;
89844 - goto munmap_back;
89845 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89846 }
89847
89848 /* Check against address space limits *after* clearing old maps... */
89849 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
89850 + if (!may_expand_vm(mm, charged))
89851 return -ENOMEM;
89852
89853 if (mm->map_count > sysctl_max_map_count)
89854 return -ENOMEM;
89855
89856 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
89857 + if (security_vm_enough_memory_mm(mm, charged))
89858 return -ENOMEM;
89859
89860 /* Can we just expand an old private anonymous mapping? */
89861 @@ -2672,7 +3168,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89862 */
89863 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89864 if (!vma) {
89865 - vm_unacct_memory(len >> PAGE_SHIFT);
89866 + vm_unacct_memory(charged);
89867 return -ENOMEM;
89868 }
89869
89870 @@ -2686,9 +3182,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89871 vma_link(mm, vma, prev, rb_link, rb_parent);
89872 out:
89873 perf_event_mmap(vma);
89874 - mm->total_vm += len >> PAGE_SHIFT;
89875 + mm->total_vm += charged;
89876 if (flags & VM_LOCKED)
89877 - mm->locked_vm += (len >> PAGE_SHIFT);
89878 + mm->locked_vm += charged;
89879 + track_exec_limit(mm, addr, addr + len, flags);
89880 return addr;
89881 }
89882
89883 @@ -2750,6 +3247,7 @@ void exit_mmap(struct mm_struct *mm)
89884 while (vma) {
89885 if (vma->vm_flags & VM_ACCOUNT)
89886 nr_accounted += vma_pages(vma);
89887 + vma->vm_mirror = NULL;
89888 vma = remove_vma(vma);
89889 }
89890 vm_unacct_memory(nr_accounted);
89891 @@ -2766,6 +3264,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89892 struct vm_area_struct *prev;
89893 struct rb_node **rb_link, *rb_parent;
89894
89895 +#ifdef CONFIG_PAX_SEGMEXEC
89896 + struct vm_area_struct *vma_m = NULL;
89897 +#endif
89898 +
89899 + if (security_mmap_addr(vma->vm_start))
89900 + return -EPERM;
89901 +
89902 /*
89903 * The vm_pgoff of a purely anonymous vma should be irrelevant
89904 * until its first write fault, when page's anon_vma and index
89905 @@ -2789,7 +3294,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89906 security_vm_enough_memory_mm(mm, vma_pages(vma)))
89907 return -ENOMEM;
89908
89909 +#ifdef CONFIG_PAX_SEGMEXEC
89910 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
89911 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89912 + if (!vma_m)
89913 + return -ENOMEM;
89914 + }
89915 +#endif
89916 +
89917 vma_link(mm, vma, prev, rb_link, rb_parent);
89918 +
89919 +#ifdef CONFIG_PAX_SEGMEXEC
89920 + if (vma_m)
89921 + BUG_ON(pax_mirror_vma(vma_m, vma));
89922 +#endif
89923 +
89924 return 0;
89925 }
89926
89927 @@ -2809,6 +3328,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89928 struct mempolicy *pol;
89929 bool faulted_in_anon_vma = true;
89930
89931 + BUG_ON(vma->vm_mirror);
89932 +
89933 /*
89934 * If anonymous vma has not yet been faulted, update new pgoff
89935 * to match new location, to increase its chance of merging.
89936 @@ -2875,6 +3396,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89937 return NULL;
89938 }
89939
89940 +#ifdef CONFIG_PAX_SEGMEXEC
89941 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
89942 +{
89943 + struct vm_area_struct *prev_m;
89944 + struct rb_node **rb_link_m, *rb_parent_m;
89945 + struct mempolicy *pol_m;
89946 +
89947 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
89948 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
89949 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
89950 + *vma_m = *vma;
89951 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
89952 + if (anon_vma_clone(vma_m, vma))
89953 + return -ENOMEM;
89954 + pol_m = vma_policy(vma_m);
89955 + mpol_get(pol_m);
89956 + vma_set_policy(vma_m, pol_m);
89957 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
89958 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
89959 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
89960 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
89961 + if (vma_m->vm_file)
89962 + get_file(vma_m->vm_file);
89963 + if (vma_m->vm_ops && vma_m->vm_ops->open)
89964 + vma_m->vm_ops->open(vma_m);
89965 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
89966 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
89967 + vma_m->vm_mirror = vma;
89968 + vma->vm_mirror = vma_m;
89969 + return 0;
89970 +}
89971 +#endif
89972 +
89973 /*
89974 * Return true if the calling process may expand its vm space by the passed
89975 * number of pages
89976 @@ -2886,6 +3440,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
89977
89978 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
89979
89980 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
89981 if (cur + npages > lim)
89982 return 0;
89983 return 1;
89984 @@ -2956,6 +3511,22 @@ int install_special_mapping(struct mm_struct *mm,
89985 vma->vm_start = addr;
89986 vma->vm_end = addr + len;
89987
89988 +#ifdef CONFIG_PAX_MPROTECT
89989 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89990 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89991 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
89992 + return -EPERM;
89993 + if (!(vm_flags & VM_EXEC))
89994 + vm_flags &= ~VM_MAYEXEC;
89995 +#else
89996 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89997 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89998 +#endif
89999 + else
90000 + vm_flags &= ~VM_MAYWRITE;
90001 + }
90002 +#endif
90003 +
90004 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
90005 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
90006
90007 diff --git a/mm/mprotect.c b/mm/mprotect.c
90008 index 94722a4..e661e29 100644
90009 --- a/mm/mprotect.c
90010 +++ b/mm/mprotect.c
90011 @@ -23,10 +23,18 @@
90012 #include <linux/mmu_notifier.h>
90013 #include <linux/migrate.h>
90014 #include <linux/perf_event.h>
90015 +#include <linux/sched/sysctl.h>
90016 +
90017 +#ifdef CONFIG_PAX_MPROTECT
90018 +#include <linux/elf.h>
90019 +#include <linux/binfmts.h>
90020 +#endif
90021 +
90022 #include <asm/uaccess.h>
90023 #include <asm/pgtable.h>
90024 #include <asm/cacheflush.h>
90025 #include <asm/tlbflush.h>
90026 +#include <asm/mmu_context.h>
90027
90028 #ifndef pgprot_modify
90029 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
90030 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
90031 return pages;
90032 }
90033
90034 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90035 +/* called while holding the mmap semaphor for writing except stack expansion */
90036 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
90037 +{
90038 + unsigned long oldlimit, newlimit = 0UL;
90039 +
90040 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
90041 + return;
90042 +
90043 + spin_lock(&mm->page_table_lock);
90044 + oldlimit = mm->context.user_cs_limit;
90045 + if ((prot & VM_EXEC) && oldlimit < end)
90046 + /* USER_CS limit moved up */
90047 + newlimit = end;
90048 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
90049 + /* USER_CS limit moved down */
90050 + newlimit = start;
90051 +
90052 + if (newlimit) {
90053 + mm->context.user_cs_limit = newlimit;
90054 +
90055 +#ifdef CONFIG_SMP
90056 + wmb();
90057 + cpus_clear(mm->context.cpu_user_cs_mask);
90058 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
90059 +#endif
90060 +
90061 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
90062 + }
90063 + spin_unlock(&mm->page_table_lock);
90064 + if (newlimit == end) {
90065 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
90066 +
90067 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
90068 + if (is_vm_hugetlb_page(vma))
90069 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
90070 + else
90071 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
90072 + }
90073 +}
90074 +#endif
90075 +
90076 int
90077 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90078 unsigned long start, unsigned long end, unsigned long newflags)
90079 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90080 int error;
90081 int dirty_accountable = 0;
90082
90083 +#ifdef CONFIG_PAX_SEGMEXEC
90084 + struct vm_area_struct *vma_m = NULL;
90085 + unsigned long start_m, end_m;
90086 +
90087 + start_m = start + SEGMEXEC_TASK_SIZE;
90088 + end_m = end + SEGMEXEC_TASK_SIZE;
90089 +#endif
90090 +
90091 if (newflags == oldflags) {
90092 *pprev = vma;
90093 return 0;
90094 }
90095
90096 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
90097 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
90098 +
90099 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
90100 + return -ENOMEM;
90101 +
90102 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
90103 + return -ENOMEM;
90104 + }
90105 +
90106 /*
90107 * If we make a private mapping writable we increase our commit;
90108 * but (without finer accounting) cannot reduce our commit if we
90109 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90110 }
90111 }
90112
90113 +#ifdef CONFIG_PAX_SEGMEXEC
90114 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
90115 + if (start != vma->vm_start) {
90116 + error = split_vma(mm, vma, start, 1);
90117 + if (error)
90118 + goto fail;
90119 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
90120 + *pprev = (*pprev)->vm_next;
90121 + }
90122 +
90123 + if (end != vma->vm_end) {
90124 + error = split_vma(mm, vma, end, 0);
90125 + if (error)
90126 + goto fail;
90127 + }
90128 +
90129 + if (pax_find_mirror_vma(vma)) {
90130 + error = __do_munmap(mm, start_m, end_m - start_m);
90131 + if (error)
90132 + goto fail;
90133 + } else {
90134 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90135 + if (!vma_m) {
90136 + error = -ENOMEM;
90137 + goto fail;
90138 + }
90139 + vma->vm_flags = newflags;
90140 + error = pax_mirror_vma(vma_m, vma);
90141 + if (error) {
90142 + vma->vm_flags = oldflags;
90143 + goto fail;
90144 + }
90145 + }
90146 + }
90147 +#endif
90148 +
90149 /*
90150 * First try to merge with previous and/or next vma.
90151 */
90152 @@ -296,9 +400,21 @@ success:
90153 * vm_flags and vm_page_prot are protected by the mmap_sem
90154 * held in write mode.
90155 */
90156 +
90157 +#ifdef CONFIG_PAX_SEGMEXEC
90158 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
90159 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
90160 +#endif
90161 +
90162 vma->vm_flags = newflags;
90163 +
90164 +#ifdef CONFIG_PAX_MPROTECT
90165 + if (mm->binfmt && mm->binfmt->handle_mprotect)
90166 + mm->binfmt->handle_mprotect(vma, newflags);
90167 +#endif
90168 +
90169 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
90170 - vm_get_page_prot(newflags));
90171 + vm_get_page_prot(vma->vm_flags));
90172
90173 if (vma_wants_writenotify(vma)) {
90174 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
90175 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90176 end = start + len;
90177 if (end <= start)
90178 return -ENOMEM;
90179 +
90180 +#ifdef CONFIG_PAX_SEGMEXEC
90181 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
90182 + if (end > SEGMEXEC_TASK_SIZE)
90183 + return -EINVAL;
90184 + } else
90185 +#endif
90186 +
90187 + if (end > TASK_SIZE)
90188 + return -EINVAL;
90189 +
90190 if (!arch_validate_prot(prot))
90191 return -EINVAL;
90192
90193 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90194 /*
90195 * Does the application expect PROT_READ to imply PROT_EXEC:
90196 */
90197 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
90198 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
90199 prot |= PROT_EXEC;
90200
90201 vm_flags = calc_vm_prot_bits(prot);
90202 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90203 if (start > vma->vm_start)
90204 prev = vma;
90205
90206 +#ifdef CONFIG_PAX_MPROTECT
90207 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
90208 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
90209 +#endif
90210 +
90211 for (nstart = start ; ; ) {
90212 unsigned long newflags;
90213
90214 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90215
90216 /* newflags >> 4 shift VM_MAY% in place of VM_% */
90217 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
90218 + if (prot & (PROT_WRITE | PROT_EXEC))
90219 + gr_log_rwxmprotect(vma);
90220 +
90221 + error = -EACCES;
90222 + goto out;
90223 + }
90224 +
90225 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
90226 error = -EACCES;
90227 goto out;
90228 }
90229 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90230 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
90231 if (error)
90232 goto out;
90233 +
90234 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
90235 +
90236 nstart = tmp;
90237
90238 if (nstart < prev->vm_end)
90239 diff --git a/mm/mremap.c b/mm/mremap.c
90240 index 463a257..c0c7a92 100644
90241 --- a/mm/mremap.c
90242 +++ b/mm/mremap.c
90243 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
90244 continue;
90245 pte = ptep_get_and_clear(mm, old_addr, old_pte);
90246 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
90247 +
90248 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90249 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
90250 + pte = pte_exprotect(pte);
90251 +#endif
90252 +
90253 set_pte_at(mm, new_addr, new_pte, pte);
90254 }
90255
90256 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
90257 if (is_vm_hugetlb_page(vma))
90258 goto Einval;
90259
90260 +#ifdef CONFIG_PAX_SEGMEXEC
90261 + if (pax_find_mirror_vma(vma))
90262 + goto Einval;
90263 +#endif
90264 +
90265 /* We can't remap across vm area boundaries */
90266 if (old_len > vma->vm_end - addr)
90267 goto Efault;
90268 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
90269 unsigned long ret = -EINVAL;
90270 unsigned long charged = 0;
90271 unsigned long map_flags;
90272 + unsigned long pax_task_size = TASK_SIZE;
90273
90274 if (new_addr & ~PAGE_MASK)
90275 goto out;
90276
90277 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
90278 +#ifdef CONFIG_PAX_SEGMEXEC
90279 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90280 + pax_task_size = SEGMEXEC_TASK_SIZE;
90281 +#endif
90282 +
90283 + pax_task_size -= PAGE_SIZE;
90284 +
90285 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
90286 goto out;
90287
90288 /* Check if the location we're moving into overlaps the
90289 * old location at all, and fail if it does.
90290 */
90291 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
90292 - goto out;
90293 -
90294 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
90295 + if (addr + old_len > new_addr && new_addr + new_len > addr)
90296 goto out;
90297
90298 ret = do_munmap(mm, new_addr, new_len);
90299 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90300 unsigned long ret = -EINVAL;
90301 unsigned long charged = 0;
90302 bool locked = false;
90303 + unsigned long pax_task_size = TASK_SIZE;
90304
90305 down_write(&current->mm->mmap_sem);
90306
90307 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90308 if (!new_len)
90309 goto out;
90310
90311 +#ifdef CONFIG_PAX_SEGMEXEC
90312 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90313 + pax_task_size = SEGMEXEC_TASK_SIZE;
90314 +#endif
90315 +
90316 + pax_task_size -= PAGE_SIZE;
90317 +
90318 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
90319 + old_len > pax_task_size || addr > pax_task_size-old_len)
90320 + goto out;
90321 +
90322 if (flags & MREMAP_FIXED) {
90323 if (flags & MREMAP_MAYMOVE)
90324 ret = mremap_to(addr, old_len, new_addr, new_len,
90325 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90326 new_addr = addr;
90327 }
90328 ret = addr;
90329 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
90330 goto out;
90331 }
90332 }
90333 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90334 goto out;
90335 }
90336
90337 + map_flags = vma->vm_flags;
90338 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
90339 + if (!(ret & ~PAGE_MASK)) {
90340 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
90341 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
90342 + }
90343 }
90344 out:
90345 if (ret & ~PAGE_MASK)
90346 diff --git a/mm/nommu.c b/mm/nommu.c
90347 index 298884d..5f74980 100644
90348 --- a/mm/nommu.c
90349 +++ b/mm/nommu.c
90350 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
90351 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
90352 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
90353 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
90354 -int heap_stack_gap = 0;
90355
90356 atomic_long_t mmap_pages_allocated;
90357
90358 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
90359 EXPORT_SYMBOL(find_vma);
90360
90361 /*
90362 - * find a VMA
90363 - * - we don't extend stack VMAs under NOMMU conditions
90364 - */
90365 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
90366 -{
90367 - return find_vma(mm, addr);
90368 -}
90369 -
90370 -/*
90371 * expand a stack to a given address
90372 * - not supported under NOMMU conditions
90373 */
90374 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90375
90376 /* most fields are the same, copy all, and then fixup */
90377 *new = *vma;
90378 + INIT_LIST_HEAD(&new->anon_vma_chain);
90379 *region = *vma->vm_region;
90380 new->vm_region = region;
90381
90382 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
90383 }
90384 EXPORT_SYMBOL(generic_file_remap_pages);
90385
90386 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90387 - unsigned long addr, void *buf, int len, int write)
90388 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90389 + unsigned long addr, void *buf, size_t len, int write)
90390 {
90391 struct vm_area_struct *vma;
90392
90393 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90394 *
90395 * The caller must hold a reference on @mm.
90396 */
90397 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90398 - void *buf, int len, int write)
90399 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
90400 + void *buf, size_t len, int write)
90401 {
90402 return __access_remote_vm(NULL, mm, addr, buf, len, write);
90403 }
90404 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90405 * Access another process' address space.
90406 * - source/target buffer must be kernel space
90407 */
90408 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
90409 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
90410 {
90411 struct mm_struct *mm;
90412
90413 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
90414 index 4514ad7..92eaa1c 100644
90415 --- a/mm/page-writeback.c
90416 +++ b/mm/page-writeback.c
90417 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
90418 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
90419 * - the bdi dirty thresh drops quickly due to change of JBOD workload
90420 */
90421 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
90422 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
90423 unsigned long thresh,
90424 unsigned long bg_thresh,
90425 unsigned long dirty,
90426 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
90427 }
90428 }
90429
90430 -static struct notifier_block __cpuinitdata ratelimit_nb = {
90431 +static struct notifier_block ratelimit_nb = {
90432 .notifier_call = ratelimit_handler,
90433 .next = NULL,
90434 };
90435 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
90436 index 2ee0fd3..6e2edfb 100644
90437 --- a/mm/page_alloc.c
90438 +++ b/mm/page_alloc.c
90439 @@ -60,6 +60,7 @@
90440 #include <linux/page-debug-flags.h>
90441 #include <linux/hugetlb.h>
90442 #include <linux/sched/rt.h>
90443 +#include <linux/random.h>
90444
90445 #include <asm/tlbflush.h>
90446 #include <asm/div64.h>
90447 @@ -345,7 +346,7 @@ out:
90448 * This usage means that zero-order pages may not be compound.
90449 */
90450
90451 -static void free_compound_page(struct page *page)
90452 +void free_compound_page(struct page *page)
90453 {
90454 __free_pages_ok(page, compound_order(page));
90455 }
90456 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90457 int i;
90458 int bad = 0;
90459
90460 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90461 + unsigned long index = 1UL << order;
90462 +#endif
90463 +
90464 trace_mm_page_free(page, order);
90465 kmemcheck_free_shadow(page, order);
90466
90467 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90468 debug_check_no_obj_freed(page_address(page),
90469 PAGE_SIZE << order);
90470 }
90471 +
90472 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90473 + for (; index; --index)
90474 + sanitize_highpage(page + index - 1);
90475 +#endif
90476 +
90477 arch_free_page(page, order);
90478 kernel_map_pages(page, 1 << order, 0);
90479
90480 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90481 local_irq_restore(flags);
90482 }
90483
90484 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90485 +bool __meminitdata extra_latent_entropy;
90486 +
90487 +static int __init setup_pax_extra_latent_entropy(char *str)
90488 +{
90489 + extra_latent_entropy = true;
90490 + return 0;
90491 +}
90492 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90493 +
90494 +volatile u64 latent_entropy;
90495 +#endif
90496 +
90497 /*
90498 * Read access to zone->managed_pages is safe because it's unsigned long,
90499 * but we still need to serialize writers. Currently all callers of
90500 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
90501 set_page_count(p, 0);
90502 }
90503
90504 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90505 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90506 + u64 hash = 0;
90507 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90508 + const u64 *data = lowmem_page_address(page);
90509 +
90510 + for (index = 0; index < end; index++)
90511 + hash ^= hash + data[index];
90512 + latent_entropy ^= hash;
90513 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90514 + }
90515 +#endif
90516 +
90517 page_zone(page)->managed_pages += 1 << order;
90518 set_page_refcounted(page);
90519 __free_pages(page, order);
90520 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90521 arch_alloc_page(page, order);
90522 kernel_map_pages(page, 1 << order, 1);
90523
90524 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90525 if (gfp_flags & __GFP_ZERO)
90526 prep_zero_page(page, order, gfp_flags);
90527 +#endif
90528
90529 if (order && (gfp_flags & __GFP_COMP))
90530 prep_compound_page(page, order);
90531 diff --git a/mm/page_io.c b/mm/page_io.c
90532 index a8a3ef4..7260a60 100644
90533 --- a/mm/page_io.c
90534 +++ b/mm/page_io.c
90535 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90536 struct file *swap_file = sis->swap_file;
90537 struct address_space *mapping = swap_file->f_mapping;
90538 struct iovec iov = {
90539 - .iov_base = kmap(page),
90540 + .iov_base = (void __force_user *)kmap(page),
90541 .iov_len = PAGE_SIZE,
90542 };
90543
90544 diff --git a/mm/percpu.c b/mm/percpu.c
90545 index 8c8e08f..73a5cda 100644
90546 --- a/mm/percpu.c
90547 +++ b/mm/percpu.c
90548 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90549 static unsigned int pcpu_high_unit_cpu __read_mostly;
90550
90551 /* the address of the first chunk which starts with the kernel static area */
90552 -void *pcpu_base_addr __read_mostly;
90553 +void *pcpu_base_addr __read_only;
90554 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90555
90556 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90557 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90558 index fd26d04..0cea1b0 100644
90559 --- a/mm/process_vm_access.c
90560 +++ b/mm/process_vm_access.c
90561 @@ -13,6 +13,7 @@
90562 #include <linux/uio.h>
90563 #include <linux/sched.h>
90564 #include <linux/highmem.h>
90565 +#include <linux/security.h>
90566 #include <linux/ptrace.h>
90567 #include <linux/slab.h>
90568 #include <linux/syscalls.h>
90569 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90570 size_t iov_l_curr_offset = 0;
90571 ssize_t iov_len;
90572
90573 + return -ENOSYS; // PaX: until properly audited
90574 +
90575 /*
90576 * Work out how many pages of struct pages we're going to need
90577 * when eventually calling get_user_pages
90578 */
90579 for (i = 0; i < riovcnt; i++) {
90580 iov_len = rvec[i].iov_len;
90581 - if (iov_len > 0) {
90582 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90583 - + iov_len)
90584 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90585 - / PAGE_SIZE + 1;
90586 - nr_pages = max(nr_pages, nr_pages_iov);
90587 - }
90588 + if (iov_len <= 0)
90589 + continue;
90590 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90591 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90592 + nr_pages = max(nr_pages, nr_pages_iov);
90593 }
90594
90595 if (nr_pages == 0)
90596 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90597 goto free_proc_pages;
90598 }
90599
90600 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90601 + rc = -EPERM;
90602 + goto put_task_struct;
90603 + }
90604 +
90605 mm = mm_access(task, PTRACE_MODE_ATTACH);
90606 if (!mm || IS_ERR(mm)) {
90607 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90608 diff --git a/mm/rmap.c b/mm/rmap.c
90609 index 6280da8..b5c090e 100644
90610 --- a/mm/rmap.c
90611 +++ b/mm/rmap.c
90612 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90613 struct anon_vma *anon_vma = vma->anon_vma;
90614 struct anon_vma_chain *avc;
90615
90616 +#ifdef CONFIG_PAX_SEGMEXEC
90617 + struct anon_vma_chain *avc_m = NULL;
90618 +#endif
90619 +
90620 might_sleep();
90621 if (unlikely(!anon_vma)) {
90622 struct mm_struct *mm = vma->vm_mm;
90623 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90624 if (!avc)
90625 goto out_enomem;
90626
90627 +#ifdef CONFIG_PAX_SEGMEXEC
90628 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
90629 + if (!avc_m)
90630 + goto out_enomem_free_avc;
90631 +#endif
90632 +
90633 anon_vma = find_mergeable_anon_vma(vma);
90634 allocated = NULL;
90635 if (!anon_vma) {
90636 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90637 /* page_table_lock to protect against threads */
90638 spin_lock(&mm->page_table_lock);
90639 if (likely(!vma->anon_vma)) {
90640 +
90641 +#ifdef CONFIG_PAX_SEGMEXEC
90642 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
90643 +
90644 + if (vma_m) {
90645 + BUG_ON(vma_m->anon_vma);
90646 + vma_m->anon_vma = anon_vma;
90647 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
90648 + avc_m = NULL;
90649 + }
90650 +#endif
90651 +
90652 vma->anon_vma = anon_vma;
90653 anon_vma_chain_link(vma, avc, anon_vma);
90654 allocated = NULL;
90655 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90656
90657 if (unlikely(allocated))
90658 put_anon_vma(allocated);
90659 +
90660 +#ifdef CONFIG_PAX_SEGMEXEC
90661 + if (unlikely(avc_m))
90662 + anon_vma_chain_free(avc_m);
90663 +#endif
90664 +
90665 if (unlikely(avc))
90666 anon_vma_chain_free(avc);
90667 }
90668 return 0;
90669
90670 out_enomem_free_avc:
90671 +
90672 +#ifdef CONFIG_PAX_SEGMEXEC
90673 + if (avc_m)
90674 + anon_vma_chain_free(avc_m);
90675 +#endif
90676 +
90677 anon_vma_chain_free(avc);
90678 out_enomem:
90679 return -ENOMEM;
90680 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
90681 * Attach the anon_vmas from src to dst.
90682 * Returns 0 on success, -ENOMEM on failure.
90683 */
90684 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90685 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
90686 {
90687 struct anon_vma_chain *avc, *pavc;
90688 struct anon_vma *root = NULL;
90689 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90690 * the corresponding VMA in the parent process is attached to.
90691 * Returns 0 on success, non-zero on failure.
90692 */
90693 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
90694 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
90695 {
90696 struct anon_vma_chain *avc;
90697 struct anon_vma *anon_vma;
90698 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
90699 void __init anon_vma_init(void)
90700 {
90701 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
90702 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
90703 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
90704 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
90705 + anon_vma_ctor);
90706 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
90707 + SLAB_PANIC|SLAB_NO_SANITIZE);
90708 }
90709
90710 /*
90711 diff --git a/mm/shmem.c b/mm/shmem.c
90712 index 5e6a842..b41916e 100644
90713 --- a/mm/shmem.c
90714 +++ b/mm/shmem.c
90715 @@ -33,7 +33,7 @@
90716 #include <linux/swap.h>
90717 #include <linux/aio.h>
90718
90719 -static struct vfsmount *shm_mnt;
90720 +struct vfsmount *shm_mnt;
90721
90722 #ifdef CONFIG_SHMEM
90723 /*
90724 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
90725 #define BOGO_DIRENT_SIZE 20
90726
90727 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
90728 -#define SHORT_SYMLINK_LEN 128
90729 +#define SHORT_SYMLINK_LEN 64
90730
90731 /*
90732 * shmem_fallocate and shmem_writepage communicate via inode->i_private
90733 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
90734 static int shmem_xattr_validate(const char *name)
90735 {
90736 struct { const char *prefix; size_t len; } arr[] = {
90737 +
90738 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90739 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
90740 +#endif
90741 +
90742 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
90743 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
90744 };
90745 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
90746 if (err)
90747 return err;
90748
90749 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90750 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
90751 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
90752 + return -EOPNOTSUPP;
90753 + if (size > 8)
90754 + return -EINVAL;
90755 + }
90756 +#endif
90757 +
90758 return simple_xattr_set(&info->xattrs, name, value, size, flags);
90759 }
90760
90761 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
90762 int err = -ENOMEM;
90763
90764 /* Round up to L1_CACHE_BYTES to resist false sharing */
90765 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
90766 - L1_CACHE_BYTES), GFP_KERNEL);
90767 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
90768 if (!sbinfo)
90769 return -ENOMEM;
90770
90771 diff --git a/mm/slab.c b/mm/slab.c
90772 index bd88411..2d46fd6 100644
90773 --- a/mm/slab.c
90774 +++ b/mm/slab.c
90775 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90776 if ((x)->max_freeable < i) \
90777 (x)->max_freeable = i; \
90778 } while (0)
90779 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
90780 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
90781 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
90782 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
90783 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
90784 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
90785 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
90786 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
90787 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
90788 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
90789 #else
90790 #define STATS_INC_ACTIVE(x) do { } while (0)
90791 #define STATS_DEC_ACTIVE(x) do { } while (0)
90792 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90793 #define STATS_INC_ALLOCMISS(x) do { } while (0)
90794 #define STATS_INC_FREEHIT(x) do { } while (0)
90795 #define STATS_INC_FREEMISS(x) do { } while (0)
90796 +#define STATS_INC_SANITIZED(x) do { } while (0)
90797 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
90798 #endif
90799
90800 #if DEBUG
90801 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
90802 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
90803 */
90804 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
90805 - const struct slab *slab, void *obj)
90806 + const struct slab *slab, const void *obj)
90807 {
90808 u32 offset = (obj - slab->s_mem);
90809 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
90810 @@ -1384,7 +1388,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
90811 return notifier_from_errno(err);
90812 }
90813
90814 -static struct notifier_block __cpuinitdata cpucache_notifier = {
90815 +static struct notifier_block cpucache_notifier = {
90816 &cpuup_callback, NULL, 0
90817 };
90818
90819 @@ -1565,12 +1569,12 @@ void __init kmem_cache_init(void)
90820 */
90821
90822 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
90823 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
90824 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90825
90826 if (INDEX_AC != INDEX_NODE)
90827 kmalloc_caches[INDEX_NODE] =
90828 create_kmalloc_cache("kmalloc-node",
90829 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
90830 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90831
90832 slab_early_init = 0;
90833
90834 @@ -3583,6 +3587,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
90835 struct array_cache *ac = cpu_cache_get(cachep);
90836
90837 check_irq_off();
90838 +
90839 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90840 + if (pax_sanitize_slab) {
90841 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
90842 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
90843 +
90844 + if (cachep->ctor)
90845 + cachep->ctor(objp);
90846 +
90847 + STATS_INC_SANITIZED(cachep);
90848 + } else
90849 + STATS_INC_NOT_SANITIZED(cachep);
90850 + }
90851 +#endif
90852 +
90853 kmemleak_free_recursive(objp, cachep->flags);
90854 objp = cache_free_debugcheck(cachep, objp, caller);
90855
90856 @@ -3800,6 +3819,7 @@ void kfree(const void *objp)
90857
90858 if (unlikely(ZERO_OR_NULL_PTR(objp)))
90859 return;
90860 + VM_BUG_ON(!virt_addr_valid(objp));
90861 local_irq_save(flags);
90862 kfree_debugcheck(objp);
90863 c = virt_to_cache(objp);
90864 @@ -4241,14 +4261,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
90865 }
90866 /* cpu stats */
90867 {
90868 - unsigned long allochit = atomic_read(&cachep->allochit);
90869 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
90870 - unsigned long freehit = atomic_read(&cachep->freehit);
90871 - unsigned long freemiss = atomic_read(&cachep->freemiss);
90872 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
90873 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
90874 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
90875 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
90876
90877 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
90878 allochit, allocmiss, freehit, freemiss);
90879 }
90880 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90881 + {
90882 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
90883 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
90884 +
90885 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
90886 + }
90887 +#endif
90888 #endif
90889 }
90890
90891 @@ -4476,13 +4504,71 @@ static const struct file_operations proc_slabstats_operations = {
90892 static int __init slab_proc_init(void)
90893 {
90894 #ifdef CONFIG_DEBUG_SLAB_LEAK
90895 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
90896 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
90897 #endif
90898 return 0;
90899 }
90900 module_init(slab_proc_init);
90901 #endif
90902
90903 +bool is_usercopy_object(const void *ptr)
90904 +{
90905 + struct page *page;
90906 + struct kmem_cache *cachep;
90907 +
90908 + if (ZERO_OR_NULL_PTR(ptr))
90909 + return false;
90910 +
90911 + if (!slab_is_available())
90912 + return false;
90913 +
90914 + if (!virt_addr_valid(ptr))
90915 + return false;
90916 +
90917 + page = virt_to_head_page(ptr);
90918 +
90919 + if (!PageSlab(page))
90920 + return false;
90921 +
90922 + cachep = page->slab_cache;
90923 + return cachep->flags & SLAB_USERCOPY;
90924 +}
90925 +
90926 +#ifdef CONFIG_PAX_USERCOPY
90927 +const char *check_heap_object(const void *ptr, unsigned long n)
90928 +{
90929 + struct page *page;
90930 + struct kmem_cache *cachep;
90931 + struct slab *slabp;
90932 + unsigned int objnr;
90933 + unsigned long offset;
90934 +
90935 + if (ZERO_OR_NULL_PTR(ptr))
90936 + return "<null>";
90937 +
90938 + if (!virt_addr_valid(ptr))
90939 + return NULL;
90940 +
90941 + page = virt_to_head_page(ptr);
90942 +
90943 + if (!PageSlab(page))
90944 + return NULL;
90945 +
90946 + cachep = page->slab_cache;
90947 + if (!(cachep->flags & SLAB_USERCOPY))
90948 + return cachep->name;
90949 +
90950 + slabp = page->slab_page;
90951 + objnr = obj_to_index(cachep, slabp, ptr);
90952 + BUG_ON(objnr >= cachep->num);
90953 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
90954 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
90955 + return NULL;
90956 +
90957 + return cachep->name;
90958 +}
90959 +#endif
90960 +
90961 /**
90962 * ksize - get the actual amount of memory allocated for a given object
90963 * @objp: Pointer to the object
90964 diff --git a/mm/slab.h b/mm/slab.h
90965 index f96b49e..db1d204 100644
90966 --- a/mm/slab.h
90967 +++ b/mm/slab.h
90968 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
90969 /* The slab cache that manages slab cache information */
90970 extern struct kmem_cache *kmem_cache;
90971
90972 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90973 +#ifdef CONFIG_X86_64
90974 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
90975 +#else
90976 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
90977 +#endif
90978 +extern bool pax_sanitize_slab;
90979 +#endif
90980 +
90981 unsigned long calculate_alignment(unsigned long flags,
90982 unsigned long align, unsigned long size);
90983
90984 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90985
90986 /* Legal flag mask for kmem_cache_create(), for various configurations */
90987 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
90988 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
90989 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
90990 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
90991
90992 #if defined(CONFIG_DEBUG_SLAB)
90993 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
90994 @@ -229,6 +239,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
90995 return s;
90996
90997 page = virt_to_head_page(x);
90998 +
90999 + BUG_ON(!PageSlab(page));
91000 +
91001 cachep = page->slab_cache;
91002 if (slab_equal_or_root(cachep, s))
91003 return cachep;
91004 diff --git a/mm/slab_common.c b/mm/slab_common.c
91005 index 2d41450..4efe6ee 100644
91006 --- a/mm/slab_common.c
91007 +++ b/mm/slab_common.c
91008 @@ -22,11 +22,22 @@
91009
91010 #include "slab.h"
91011
91012 -enum slab_state slab_state;
91013 +enum slab_state slab_state __read_only;
91014 LIST_HEAD(slab_caches);
91015 DEFINE_MUTEX(slab_mutex);
91016 struct kmem_cache *kmem_cache;
91017
91018 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91019 +bool pax_sanitize_slab __read_only = true;
91020 +static int __init pax_sanitize_slab_setup(char *str)
91021 +{
91022 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
91023 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
91024 + return 1;
91025 +}
91026 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
91027 +#endif
91028 +
91029 #ifdef CONFIG_DEBUG_VM
91030 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
91031 size_t size)
91032 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
91033
91034 err = __kmem_cache_create(s, flags);
91035 if (!err) {
91036 - s->refcount = 1;
91037 + atomic_set(&s->refcount, 1);
91038 list_add(&s->list, &slab_caches);
91039 memcg_cache_list_add(memcg, s);
91040 } else {
91041 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
91042
91043 get_online_cpus();
91044 mutex_lock(&slab_mutex);
91045 - s->refcount--;
91046 - if (!s->refcount) {
91047 + if (atomic_dec_and_test(&s->refcount)) {
91048 list_del(&s->list);
91049
91050 if (!__kmem_cache_shutdown(s)) {
91051 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
91052 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
91053 name, size, err);
91054
91055 - s->refcount = -1; /* Exempt from merging for now */
91056 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
91057 }
91058
91059 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91060 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91061
91062 create_boot_cache(s, name, size, flags);
91063 list_add(&s->list, &slab_caches);
91064 - s->refcount = 1;
91065 + atomic_set(&s->refcount, 1);
91066 return s;
91067 }
91068
91069 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
91070 EXPORT_SYMBOL(kmalloc_dma_caches);
91071 #endif
91072
91073 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91074 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
91075 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
91076 +#endif
91077 +
91078 /*
91079 * Conversion table for small slabs sizes / 8 to the index in the
91080 * kmalloc array. This is necessary for slabs < 192 since we have non power
91081 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
91082 return kmalloc_dma_caches[index];
91083
91084 #endif
91085 +
91086 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91087 + if (unlikely((flags & GFP_USERCOPY)))
91088 + return kmalloc_usercopy_caches[index];
91089 +
91090 +#endif
91091 +
91092 return kmalloc_caches[index];
91093 }
91094
91095 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
91096 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
91097 if (!kmalloc_caches[i]) {
91098 kmalloc_caches[i] = create_kmalloc_cache(NULL,
91099 - 1 << i, flags);
91100 + 1 << i, SLAB_USERCOPY | flags);
91101 }
91102
91103 /*
91104 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
91105 * earlier power of two caches
91106 */
91107 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
91108 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
91109 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
91110
91111 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
91112 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
91113 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
91114 }
91115
91116 /* Kmalloc array is now usable */
91117 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
91118 }
91119 }
91120 #endif
91121 +
91122 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91123 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
91124 + struct kmem_cache *s = kmalloc_caches[i];
91125 +
91126 + if (s) {
91127 + int size = kmalloc_size(i);
91128 + char *n = kasprintf(GFP_NOWAIT,
91129 + "usercopy-kmalloc-%d", size);
91130 +
91131 + BUG_ON(!n);
91132 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
91133 + size, SLAB_USERCOPY | flags);
91134 + }
91135 + }
91136 +#endif
91137 +
91138 }
91139 #endif /* !CONFIG_SLOB */
91140
91141 @@ -516,6 +555,9 @@ void print_slabinfo_header(struct seq_file *m)
91142 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
91143 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
91144 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
91145 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91146 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
91147 +#endif
91148 #endif
91149 seq_putc(m, '\n');
91150 }
91151 diff --git a/mm/slob.c b/mm/slob.c
91152 index eeed4a0..bb0e9ab 100644
91153 --- a/mm/slob.c
91154 +++ b/mm/slob.c
91155 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
91156 /*
91157 * Return the size of a slob block.
91158 */
91159 -static slobidx_t slob_units(slob_t *s)
91160 +static slobidx_t slob_units(const slob_t *s)
91161 {
91162 if (s->units > 0)
91163 return s->units;
91164 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
91165 /*
91166 * Return the next free slob block pointer after this one.
91167 */
91168 -static slob_t *slob_next(slob_t *s)
91169 +static slob_t *slob_next(const slob_t *s)
91170 {
91171 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
91172 slobidx_t next;
91173 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
91174 /*
91175 * Returns true if s is the last free block in its page.
91176 */
91177 -static int slob_last(slob_t *s)
91178 +static int slob_last(const slob_t *s)
91179 {
91180 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
91181 }
91182
91183 -static void *slob_new_pages(gfp_t gfp, int order, int node)
91184 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
91185 {
91186 - void *page;
91187 + struct page *page;
91188
91189 #ifdef CONFIG_NUMA
91190 if (node != NUMA_NO_NODE)
91191 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
91192 if (!page)
91193 return NULL;
91194
91195 - return page_address(page);
91196 + __SetPageSlab(page);
91197 + return page;
91198 }
91199
91200 -static void slob_free_pages(void *b, int order)
91201 +static void slob_free_pages(struct page *sp, int order)
91202 {
91203 if (current->reclaim_state)
91204 current->reclaim_state->reclaimed_slab += 1 << order;
91205 - free_pages((unsigned long)b, order);
91206 + __ClearPageSlab(sp);
91207 + page_mapcount_reset(sp);
91208 + sp->private = 0;
91209 + __free_pages(sp, order);
91210 }
91211
91212 /*
91213 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
91214
91215 /* Not enough space: must allocate a new page */
91216 if (!b) {
91217 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91218 - if (!b)
91219 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91220 + if (!sp)
91221 return NULL;
91222 - sp = virt_to_page(b);
91223 - __SetPageSlab(sp);
91224 + b = page_address(sp);
91225
91226 spin_lock_irqsave(&slob_lock, flags);
91227 sp->units = SLOB_UNITS(PAGE_SIZE);
91228 sp->freelist = b;
91229 + sp->private = 0;
91230 INIT_LIST_HEAD(&sp->list);
91231 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
91232 set_slob_page_free(sp, slob_list);
91233 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
91234 if (slob_page_free(sp))
91235 clear_slob_page_free(sp);
91236 spin_unlock_irqrestore(&slob_lock, flags);
91237 - __ClearPageSlab(sp);
91238 - page_mapcount_reset(sp);
91239 - slob_free_pages(b, 0);
91240 + slob_free_pages(sp, 0);
91241 return;
91242 }
91243
91244 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91245 + if (pax_sanitize_slab)
91246 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
91247 +#endif
91248 +
91249 if (!slob_page_free(sp)) {
91250 /* This slob page is about to become partially free. Easy! */
91251 sp->units = units;
91252 @@ -424,11 +431,10 @@ out:
91253 */
91254
91255 static __always_inline void *
91256 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91257 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
91258 {
91259 - unsigned int *m;
91260 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91261 - void *ret;
91262 + slob_t *m;
91263 + void *ret = NULL;
91264
91265 gfp &= gfp_allowed_mask;
91266
91267 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91268
91269 if (!m)
91270 return NULL;
91271 - *m = size;
91272 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
91273 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
91274 + m[0].units = size;
91275 + m[1].units = align;
91276 ret = (void *)m + align;
91277
91278 trace_kmalloc_node(caller, ret,
91279 size, size + align, gfp, node);
91280 } else {
91281 unsigned int order = get_order(size);
91282 + struct page *page;
91283
91284 if (likely(order))
91285 gfp |= __GFP_COMP;
91286 - ret = slob_new_pages(gfp, order, node);
91287 + page = slob_new_pages(gfp, order, node);
91288 + if (page) {
91289 + ret = page_address(page);
91290 + page->private = size;
91291 + }
91292
91293 trace_kmalloc_node(caller, ret,
91294 size, PAGE_SIZE << order, gfp, node);
91295 }
91296
91297 - kmemleak_alloc(ret, size, 1, gfp);
91298 + return ret;
91299 +}
91300 +
91301 +static __always_inline void *
91302 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91303 +{
91304 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91305 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
91306 +
91307 + if (!ZERO_OR_NULL_PTR(ret))
91308 + kmemleak_alloc(ret, size, 1, gfp);
91309 return ret;
91310 }
91311
91312 @@ -493,34 +517,112 @@ void kfree(const void *block)
91313 return;
91314 kmemleak_free(block);
91315
91316 + VM_BUG_ON(!virt_addr_valid(block));
91317 sp = virt_to_page(block);
91318 - if (PageSlab(sp)) {
91319 + VM_BUG_ON(!PageSlab(sp));
91320 + if (!sp->private) {
91321 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91322 - unsigned int *m = (unsigned int *)(block - align);
91323 - slob_free(m, *m + align);
91324 - } else
91325 + slob_t *m = (slob_t *)(block - align);
91326 + slob_free(m, m[0].units + align);
91327 + } else {
91328 + __ClearPageSlab(sp);
91329 + page_mapcount_reset(sp);
91330 + sp->private = 0;
91331 __free_pages(sp, compound_order(sp));
91332 + }
91333 }
91334 EXPORT_SYMBOL(kfree);
91335
91336 +bool is_usercopy_object(const void *ptr)
91337 +{
91338 + if (!slab_is_available())
91339 + return false;
91340 +
91341 + // PAX: TODO
91342 +
91343 + return false;
91344 +}
91345 +
91346 +#ifdef CONFIG_PAX_USERCOPY
91347 +const char *check_heap_object(const void *ptr, unsigned long n)
91348 +{
91349 + struct page *page;
91350 + const slob_t *free;
91351 + const void *base;
91352 + unsigned long flags;
91353 +
91354 + if (ZERO_OR_NULL_PTR(ptr))
91355 + return "<null>";
91356 +
91357 + if (!virt_addr_valid(ptr))
91358 + return NULL;
91359 +
91360 + page = virt_to_head_page(ptr);
91361 + if (!PageSlab(page))
91362 + return NULL;
91363 +
91364 + if (page->private) {
91365 + base = page;
91366 + if (base <= ptr && n <= page->private - (ptr - base))
91367 + return NULL;
91368 + return "<slob>";
91369 + }
91370 +
91371 + /* some tricky double walking to find the chunk */
91372 + spin_lock_irqsave(&slob_lock, flags);
91373 + base = (void *)((unsigned long)ptr & PAGE_MASK);
91374 + free = page->freelist;
91375 +
91376 + while (!slob_last(free) && (void *)free <= ptr) {
91377 + base = free + slob_units(free);
91378 + free = slob_next(free);
91379 + }
91380 +
91381 + while (base < (void *)free) {
91382 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
91383 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
91384 + int offset;
91385 +
91386 + if (ptr < base + align)
91387 + break;
91388 +
91389 + offset = ptr - base - align;
91390 + if (offset >= m) {
91391 + base += size;
91392 + continue;
91393 + }
91394 +
91395 + if (n > m - offset)
91396 + break;
91397 +
91398 + spin_unlock_irqrestore(&slob_lock, flags);
91399 + return NULL;
91400 + }
91401 +
91402 + spin_unlock_irqrestore(&slob_lock, flags);
91403 + return "<slob>";
91404 +}
91405 +#endif
91406 +
91407 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
91408 size_t ksize(const void *block)
91409 {
91410 struct page *sp;
91411 int align;
91412 - unsigned int *m;
91413 + slob_t *m;
91414
91415 BUG_ON(!block);
91416 if (unlikely(block == ZERO_SIZE_PTR))
91417 return 0;
91418
91419 sp = virt_to_page(block);
91420 - if (unlikely(!PageSlab(sp)))
91421 - return PAGE_SIZE << compound_order(sp);
91422 + VM_BUG_ON(!PageSlab(sp));
91423 + if (sp->private)
91424 + return sp->private;
91425
91426 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91427 - m = (unsigned int *)(block - align);
91428 - return SLOB_UNITS(*m) * SLOB_UNIT;
91429 + m = (slob_t *)(block - align);
91430 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
91431 }
91432 EXPORT_SYMBOL(ksize);
91433
91434 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
91435
91436 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
91437 {
91438 - void *b;
91439 + void *b = NULL;
91440
91441 flags &= gfp_allowed_mask;
91442
91443 lockdep_trace_alloc(flags);
91444
91445 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91446 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
91447 +#else
91448 if (c->size < PAGE_SIZE) {
91449 b = slob_alloc(c->size, flags, c->align, node);
91450 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91451 SLOB_UNITS(c->size) * SLOB_UNIT,
91452 flags, node);
91453 } else {
91454 - b = slob_new_pages(flags, get_order(c->size), node);
91455 + struct page *sp;
91456 +
91457 + sp = slob_new_pages(flags, get_order(c->size), node);
91458 + if (sp) {
91459 + b = page_address(sp);
91460 + sp->private = c->size;
91461 + }
91462 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91463 PAGE_SIZE << get_order(c->size),
91464 flags, node);
91465 }
91466 +#endif
91467
91468 if (c->ctor)
91469 c->ctor(b);
91470 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91471
91472 static void __kmem_cache_free(void *b, int size)
91473 {
91474 - if (size < PAGE_SIZE)
91475 + struct page *sp;
91476 +
91477 + sp = virt_to_page(b);
91478 + BUG_ON(!PageSlab(sp));
91479 + if (!sp->private)
91480 slob_free(b, size);
91481 else
91482 - slob_free_pages(b, get_order(size));
91483 + slob_free_pages(sp, get_order(size));
91484 }
91485
91486 static void kmem_rcu_free(struct rcu_head *head)
91487 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91488
91489 void kmem_cache_free(struct kmem_cache *c, void *b)
91490 {
91491 + int size = c->size;
91492 +
91493 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91494 + if (size + c->align < PAGE_SIZE) {
91495 + size += c->align;
91496 + b -= c->align;
91497 + }
91498 +#endif
91499 +
91500 kmemleak_free_recursive(b, c->flags);
91501 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91502 struct slob_rcu *slob_rcu;
91503 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91504 - slob_rcu->size = c->size;
91505 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91506 + slob_rcu->size = size;
91507 call_rcu(&slob_rcu->head, kmem_rcu_free);
91508 } else {
91509 - __kmem_cache_free(b, c->size);
91510 + __kmem_cache_free(b, size);
91511 }
91512
91513 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91514 + trace_kfree(_RET_IP_, b);
91515 +#else
91516 trace_kmem_cache_free(_RET_IP_, b);
91517 +#endif
91518 +
91519 }
91520 EXPORT_SYMBOL(kmem_cache_free);
91521
91522 diff --git a/mm/slub.c b/mm/slub.c
91523 index 57707f0..7857bd3 100644
91524 --- a/mm/slub.c
91525 +++ b/mm/slub.c
91526 @@ -198,7 +198,7 @@ struct track {
91527
91528 enum track_item { TRACK_ALLOC, TRACK_FREE };
91529
91530 -#ifdef CONFIG_SYSFS
91531 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91532 static int sysfs_slab_add(struct kmem_cache *);
91533 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91534 static void sysfs_slab_remove(struct kmem_cache *);
91535 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
91536 if (!t->addr)
91537 return;
91538
91539 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91540 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91541 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91542 #ifdef CONFIG_STACKTRACE
91543 {
91544 @@ -2594,6 +2594,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91545
91546 slab_free_hook(s, x);
91547
91548 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91549 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91550 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91551 + if (s->ctor)
91552 + s->ctor(x);
91553 + }
91554 +#endif
91555 +
91556 redo:
91557 /*
91558 * Determine the currently cpus per cpu slab.
91559 @@ -2661,7 +2669,7 @@ static int slub_min_objects;
91560 * Merge control. If this is set then no merging of slab caches will occur.
91561 * (Could be removed. This was introduced to pacify the merge skeptics.)
91562 */
91563 -static int slub_nomerge;
91564 +static int slub_nomerge = 1;
91565
91566 /*
91567 * Calculate the order of allocation given an slab object size.
91568 @@ -2938,6 +2946,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91569 s->inuse = size;
91570
91571 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91572 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91573 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91574 +#endif
91575 s->ctor)) {
91576 /*
91577 * Relocate free pointer after the object if it is not
91578 @@ -3283,6 +3294,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91579 EXPORT_SYMBOL(__kmalloc_node);
91580 #endif
91581
91582 +bool is_usercopy_object(const void *ptr)
91583 +{
91584 + struct page *page;
91585 + struct kmem_cache *s;
91586 +
91587 + if (ZERO_OR_NULL_PTR(ptr))
91588 + return false;
91589 +
91590 + if (!slab_is_available())
91591 + return false;
91592 +
91593 + if (!virt_addr_valid(ptr))
91594 + return false;
91595 +
91596 + page = virt_to_head_page(ptr);
91597 +
91598 + if (!PageSlab(page))
91599 + return false;
91600 +
91601 + s = page->slab_cache;
91602 + return s->flags & SLAB_USERCOPY;
91603 +}
91604 +
91605 +#ifdef CONFIG_PAX_USERCOPY
91606 +const char *check_heap_object(const void *ptr, unsigned long n)
91607 +{
91608 + struct page *page;
91609 + struct kmem_cache *s;
91610 + unsigned long offset;
91611 +
91612 + if (ZERO_OR_NULL_PTR(ptr))
91613 + return "<null>";
91614 +
91615 + if (!virt_addr_valid(ptr))
91616 + return NULL;
91617 +
91618 + page = virt_to_head_page(ptr);
91619 +
91620 + if (!PageSlab(page))
91621 + return NULL;
91622 +
91623 + s = page->slab_cache;
91624 + if (!(s->flags & SLAB_USERCOPY))
91625 + return s->name;
91626 +
91627 + offset = (ptr - page_address(page)) % s->size;
91628 + if (offset <= s->object_size && n <= s->object_size - offset)
91629 + return NULL;
91630 +
91631 + return s->name;
91632 +}
91633 +#endif
91634 +
91635 size_t ksize(const void *object)
91636 {
91637 struct page *page;
91638 @@ -3347,6 +3411,7 @@ void kfree(const void *x)
91639 if (unlikely(ZERO_OR_NULL_PTR(x)))
91640 return;
91641
91642 + VM_BUG_ON(!virt_addr_valid(x));
91643 page = virt_to_head_page(x);
91644 if (unlikely(!PageSlab(page))) {
91645 BUG_ON(!PageCompound(page));
91646 @@ -3652,7 +3717,7 @@ static int slab_unmergeable(struct kmem_cache *s)
91647 /*
91648 * We may have set a slab to be unmergeable during bootstrap.
91649 */
91650 - if (s->refcount < 0)
91651 + if (atomic_read(&s->refcount) < 0)
91652 return 1;
91653
91654 return 0;
91655 @@ -3710,7 +3775,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91656
91657 s = find_mergeable(memcg, size, align, flags, name, ctor);
91658 if (s) {
91659 - s->refcount++;
91660 + atomic_inc(&s->refcount);
91661 /*
91662 * Adjust the object sizes so that we clear
91663 * the complete object on kzalloc.
91664 @@ -3719,7 +3784,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91665 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
91666
91667 if (sysfs_slab_alias(s, name)) {
91668 - s->refcount--;
91669 + atomic_dec(&s->refcount);
91670 s = NULL;
91671 }
91672 }
91673 @@ -3781,7 +3846,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
91674 return NOTIFY_OK;
91675 }
91676
91677 -static struct notifier_block __cpuinitdata slab_notifier = {
91678 +static struct notifier_block slab_notifier = {
91679 .notifier_call = slab_cpuup_callback
91680 };
91681
91682 @@ -3839,7 +3904,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
91683 }
91684 #endif
91685
91686 -#ifdef CONFIG_SYSFS
91687 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91688 static int count_inuse(struct page *page)
91689 {
91690 return page->inuse;
91691 @@ -4226,12 +4291,12 @@ static void resiliency_test(void)
91692 validate_slab_cache(kmalloc_caches[9]);
91693 }
91694 #else
91695 -#ifdef CONFIG_SYSFS
91696 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91697 static void resiliency_test(void) {};
91698 #endif
91699 #endif
91700
91701 -#ifdef CONFIG_SYSFS
91702 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91703 enum slab_stat_type {
91704 SL_ALL, /* All slabs */
91705 SL_PARTIAL, /* Only partially allocated slabs */
91706 @@ -4475,7 +4540,7 @@ SLAB_ATTR_RO(ctor);
91707
91708 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
91709 {
91710 - return sprintf(buf, "%d\n", s->refcount - 1);
91711 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
91712 }
91713 SLAB_ATTR_RO(aliases);
91714
91715 @@ -4563,6 +4628,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
91716 SLAB_ATTR_RO(cache_dma);
91717 #endif
91718
91719 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91720 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
91721 +{
91722 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
91723 +}
91724 +SLAB_ATTR_RO(usercopy);
91725 +#endif
91726 +
91727 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
91728 {
91729 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
91730 @@ -4897,6 +4970,9 @@ static struct attribute *slab_attrs[] = {
91731 #ifdef CONFIG_ZONE_DMA
91732 &cache_dma_attr.attr,
91733 #endif
91734 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91735 + &usercopy_attr.attr,
91736 +#endif
91737 #ifdef CONFIG_NUMA
91738 &remote_node_defrag_ratio_attr.attr,
91739 #endif
91740 @@ -5128,6 +5204,7 @@ static char *create_unique_id(struct kmem_cache *s)
91741 return name;
91742 }
91743
91744 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91745 static int sysfs_slab_add(struct kmem_cache *s)
91746 {
91747 int err;
91748 @@ -5151,7 +5228,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
91749 }
91750
91751 s->kobj.kset = slab_kset;
91752 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
91753 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
91754 if (err) {
91755 kobject_put(&s->kobj);
91756 return err;
91757 @@ -5185,6 +5262,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
91758 kobject_del(&s->kobj);
91759 kobject_put(&s->kobj);
91760 }
91761 +#endif
91762
91763 /*
91764 * Need to buffer aliases during bootup until sysfs becomes
91765 @@ -5198,6 +5276,7 @@ struct saved_alias {
91766
91767 static struct saved_alias *alias_list;
91768
91769 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91770 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91771 {
91772 struct saved_alias *al;
91773 @@ -5220,6 +5299,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91774 alias_list = al;
91775 return 0;
91776 }
91777 +#endif
91778
91779 static int __init slab_sysfs_init(void)
91780 {
91781 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
91782 index 27eeab3..7c3f7f2 100644
91783 --- a/mm/sparse-vmemmap.c
91784 +++ b/mm/sparse-vmemmap.c
91785 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
91786 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91787 if (!p)
91788 return NULL;
91789 - pud_populate(&init_mm, pud, p);
91790 + pud_populate_kernel(&init_mm, pud, p);
91791 }
91792 return pud;
91793 }
91794 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
91795 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91796 if (!p)
91797 return NULL;
91798 - pgd_populate(&init_mm, pgd, p);
91799 + pgd_populate_kernel(&init_mm, pgd, p);
91800 }
91801 return pgd;
91802 }
91803 diff --git a/mm/sparse.c b/mm/sparse.c
91804 index 1c91f0d3..485470a 100644
91805 --- a/mm/sparse.c
91806 +++ b/mm/sparse.c
91807 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
91808
91809 for (i = 0; i < PAGES_PER_SECTION; i++) {
91810 if (PageHWPoison(&memmap[i])) {
91811 - atomic_long_sub(1, &num_poisoned_pages);
91812 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
91813 ClearPageHWPoison(&memmap[i]);
91814 }
91815 }
91816 diff --git a/mm/swap.c b/mm/swap.c
91817 index dfd7d71..ccdf688 100644
91818 --- a/mm/swap.c
91819 +++ b/mm/swap.c
91820 @@ -31,6 +31,7 @@
91821 #include <linux/memcontrol.h>
91822 #include <linux/gfp.h>
91823 #include <linux/uio.h>
91824 +#include <linux/hugetlb.h>
91825
91826 #include "internal.h"
91827
91828 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
91829
91830 __page_cache_release(page);
91831 dtor = get_compound_page_dtor(page);
91832 + if (!PageHuge(page))
91833 + BUG_ON(dtor != free_compound_page);
91834 (*dtor)(page);
91835 }
91836
91837 diff --git a/mm/swapfile.c b/mm/swapfile.c
91838 index 746af55b..7ac94ae 100644
91839 --- a/mm/swapfile.c
91840 +++ b/mm/swapfile.c
91841 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
91842
91843 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
91844 /* Activity counter to indicate that a swapon or swapoff has occurred */
91845 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
91846 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
91847
91848 static inline unsigned char swap_count(unsigned char ent)
91849 {
91850 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
91851 }
91852 filp_close(swap_file, NULL);
91853 err = 0;
91854 - atomic_inc(&proc_poll_event);
91855 + atomic_inc_unchecked(&proc_poll_event);
91856 wake_up_interruptible(&proc_poll_wait);
91857
91858 out_dput:
91859 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
91860
91861 poll_wait(file, &proc_poll_wait, wait);
91862
91863 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
91864 - seq->poll_event = atomic_read(&proc_poll_event);
91865 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
91866 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91867 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
91868 }
91869
91870 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
91871 return ret;
91872
91873 seq = file->private_data;
91874 - seq->poll_event = atomic_read(&proc_poll_event);
91875 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91876 return 0;
91877 }
91878
91879 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
91880 (frontswap_map) ? "FS" : "");
91881
91882 mutex_unlock(&swapon_mutex);
91883 - atomic_inc(&proc_poll_event);
91884 + atomic_inc_unchecked(&proc_poll_event);
91885 wake_up_interruptible(&proc_poll_wait);
91886
91887 if (S_ISREG(inode->i_mode))
91888 diff --git a/mm/util.c b/mm/util.c
91889 index ab1424d..7c5bd5a 100644
91890 --- a/mm/util.c
91891 +++ b/mm/util.c
91892 @@ -294,6 +294,12 @@ done:
91893 void arch_pick_mmap_layout(struct mm_struct *mm)
91894 {
91895 mm->mmap_base = TASK_UNMAPPED_BASE;
91896 +
91897 +#ifdef CONFIG_PAX_RANDMMAP
91898 + if (mm->pax_flags & MF_PAX_RANDMMAP)
91899 + mm->mmap_base += mm->delta_mmap;
91900 +#endif
91901 +
91902 mm->get_unmapped_area = arch_get_unmapped_area;
91903 mm->unmap_area = arch_unmap_area;
91904 }
91905 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
91906 index d365724..6cae7c2 100644
91907 --- a/mm/vmalloc.c
91908 +++ b/mm/vmalloc.c
91909 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
91910
91911 pte = pte_offset_kernel(pmd, addr);
91912 do {
91913 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91914 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91915 +
91916 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91917 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
91918 + BUG_ON(!pte_exec(*pte));
91919 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
91920 + continue;
91921 + }
91922 +#endif
91923 +
91924 + {
91925 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91926 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91927 + }
91928 } while (pte++, addr += PAGE_SIZE, addr != end);
91929 }
91930
91931 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
91932 pte = pte_alloc_kernel(pmd, addr);
91933 if (!pte)
91934 return -ENOMEM;
91935 +
91936 + pax_open_kernel();
91937 do {
91938 struct page *page = pages[*nr];
91939
91940 - if (WARN_ON(!pte_none(*pte)))
91941 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91942 + if (pgprot_val(prot) & _PAGE_NX)
91943 +#endif
91944 +
91945 + if (!pte_none(*pte)) {
91946 + pax_close_kernel();
91947 + WARN_ON(1);
91948 return -EBUSY;
91949 - if (WARN_ON(!page))
91950 + }
91951 + if (!page) {
91952 + pax_close_kernel();
91953 + WARN_ON(1);
91954 return -ENOMEM;
91955 + }
91956 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
91957 (*nr)++;
91958 } while (pte++, addr += PAGE_SIZE, addr != end);
91959 + pax_close_kernel();
91960 return 0;
91961 }
91962
91963 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
91964 pmd_t *pmd;
91965 unsigned long next;
91966
91967 - pmd = pmd_alloc(&init_mm, pud, addr);
91968 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91969 if (!pmd)
91970 return -ENOMEM;
91971 do {
91972 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
91973 pud_t *pud;
91974 unsigned long next;
91975
91976 - pud = pud_alloc(&init_mm, pgd, addr);
91977 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91978 if (!pud)
91979 return -ENOMEM;
91980 do {
91981 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
91982 if (addr >= MODULES_VADDR && addr < MODULES_END)
91983 return 1;
91984 #endif
91985 +
91986 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91987 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
91988 + return 1;
91989 +#endif
91990 +
91991 return is_vmalloc_addr(x);
91992 }
91993
91994 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
91995
91996 if (!pgd_none(*pgd)) {
91997 pud_t *pud = pud_offset(pgd, addr);
91998 +#ifdef CONFIG_X86
91999 + if (!pud_large(*pud))
92000 +#endif
92001 if (!pud_none(*pud)) {
92002 pmd_t *pmd = pmd_offset(pud, addr);
92003 +#ifdef CONFIG_X86
92004 + if (!pmd_large(*pmd))
92005 +#endif
92006 if (!pmd_none(*pmd)) {
92007 pte_t *ptep, pte;
92008
92009 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
92010 * Allocate a region of KVA of the specified size and alignment, within the
92011 * vstart and vend.
92012 */
92013 -static struct vmap_area *alloc_vmap_area(unsigned long size,
92014 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
92015 unsigned long align,
92016 unsigned long vstart, unsigned long vend,
92017 int node, gfp_t gfp_mask)
92018 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
92019 struct vm_struct *area;
92020
92021 BUG_ON(in_interrupt());
92022 +
92023 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92024 + if (flags & VM_KERNEXEC) {
92025 + if (start != VMALLOC_START || end != VMALLOC_END)
92026 + return NULL;
92027 + start = (unsigned long)MODULES_EXEC_VADDR;
92028 + end = (unsigned long)MODULES_EXEC_END;
92029 + }
92030 +#endif
92031 +
92032 if (flags & VM_IOREMAP) {
92033 int bit = fls(size);
92034
92035 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
92036 if (count > totalram_pages)
92037 return NULL;
92038
92039 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92040 + if (!(pgprot_val(prot) & _PAGE_NX))
92041 + flags |= VM_KERNEXEC;
92042 +#endif
92043 +
92044 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
92045 __builtin_return_address(0));
92046 if (!area)
92047 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
92048 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
92049 goto fail;
92050
92051 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92052 + if (!(pgprot_val(prot) & _PAGE_NX))
92053 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
92054 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
92055 + else
92056 +#endif
92057 +
92058 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
92059 start, end, node, gfp_mask, caller);
92060 if (!area)
92061 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
92062 * For tight control over page level allocator and protection flags
92063 * use __vmalloc() instead.
92064 */
92065 -
92066 void *vmalloc_exec(unsigned long size)
92067 {
92068 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
92069 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
92070 NUMA_NO_NODE, __builtin_return_address(0));
92071 }
92072
92073 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
92074 unsigned long uaddr = vma->vm_start;
92075 unsigned long usize = vma->vm_end - vma->vm_start;
92076
92077 + BUG_ON(vma->vm_mirror);
92078 +
92079 if ((PAGE_SIZE-1) & (unsigned long)addr)
92080 return -EINVAL;
92081
92082 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
92083 v->addr, v->addr + v->size, v->size);
92084
92085 if (v->caller)
92086 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92087 + seq_printf(m, " %pK", v->caller);
92088 +#else
92089 seq_printf(m, " %pS", v->caller);
92090 +#endif
92091
92092 if (v->nr_pages)
92093 seq_printf(m, " pages=%d", v->nr_pages);
92094 diff --git a/mm/vmstat.c b/mm/vmstat.c
92095 index f42745e..62f8346 100644
92096 --- a/mm/vmstat.c
92097 +++ b/mm/vmstat.c
92098 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
92099 *
92100 * vm_stat contains the global counters
92101 */
92102 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92103 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92104 EXPORT_SYMBOL(vm_stat);
92105
92106 #ifdef CONFIG_SMP
92107 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
92108 v = p->vm_stat_diff[i];
92109 p->vm_stat_diff[i] = 0;
92110 local_irq_restore(flags);
92111 - atomic_long_add(v, &zone->vm_stat[i]);
92112 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92113 global_diff[i] += v;
92114 #ifdef CONFIG_NUMA
92115 /* 3 seconds idle till flush */
92116 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
92117
92118 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
92119 if (global_diff[i])
92120 - atomic_long_add(global_diff[i], &vm_stat[i]);
92121 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
92122 }
92123
92124 /*
92125 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
92126 if (pset->vm_stat_diff[i]) {
92127 int v = pset->vm_stat_diff[i];
92128 pset->vm_stat_diff[i] = 0;
92129 - atomic_long_add(v, &zone->vm_stat[i]);
92130 - atomic_long_add(v, &vm_stat[i]);
92131 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92132 + atomic_long_add_unchecked(v, &vm_stat[i]);
92133 }
92134 }
92135 #endif
92136 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
92137 return NOTIFY_OK;
92138 }
92139
92140 -static struct notifier_block __cpuinitdata vmstat_notifier =
92141 +static struct notifier_block vmstat_notifier =
92142 { &vmstat_cpuup_callback, NULL, 0 };
92143 #endif
92144
92145 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
92146 start_cpu_timer(cpu);
92147 #endif
92148 #ifdef CONFIG_PROC_FS
92149 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
92150 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
92151 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92152 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
92153 + {
92154 + mode_t gr_mode = S_IRUGO;
92155 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92156 + gr_mode = S_IRUSR;
92157 +#endif
92158 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
92159 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
92160 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
92161 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
92162 +#else
92163 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
92164 +#endif
92165 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
92166 + }
92167 #endif
92168 return 0;
92169 }
92170 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
92171 index 9424f37..6aabf19 100644
92172 --- a/net/8021q/vlan.c
92173 +++ b/net/8021q/vlan.c
92174 @@ -469,7 +469,7 @@ out:
92175 return NOTIFY_DONE;
92176 }
92177
92178 -static struct notifier_block vlan_notifier_block __read_mostly = {
92179 +static struct notifier_block vlan_notifier_block = {
92180 .notifier_call = vlan_device_event,
92181 };
92182
92183 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
92184 err = -EPERM;
92185 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
92186 break;
92187 - if ((args.u.name_type >= 0) &&
92188 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
92189 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
92190 struct vlan_net *vn;
92191
92192 vn = net_generic(net, vlan_net_id);
92193 diff --git a/net/9p/mod.c b/net/9p/mod.c
92194 index 6ab36ae..6f1841b 100644
92195 --- a/net/9p/mod.c
92196 +++ b/net/9p/mod.c
92197 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
92198 void v9fs_register_trans(struct p9_trans_module *m)
92199 {
92200 spin_lock(&v9fs_trans_lock);
92201 - list_add_tail(&m->list, &v9fs_trans_list);
92202 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
92203 spin_unlock(&v9fs_trans_lock);
92204 }
92205 EXPORT_SYMBOL(v9fs_register_trans);
92206 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
92207 void v9fs_unregister_trans(struct p9_trans_module *m)
92208 {
92209 spin_lock(&v9fs_trans_lock);
92210 - list_del_init(&m->list);
92211 + pax_list_del_init((struct list_head *)&m->list);
92212 spin_unlock(&v9fs_trans_lock);
92213 }
92214 EXPORT_SYMBOL(v9fs_unregister_trans);
92215 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
92216 index 02efb25..41541a9 100644
92217 --- a/net/9p/trans_fd.c
92218 +++ b/net/9p/trans_fd.c
92219 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
92220 oldfs = get_fs();
92221 set_fs(get_ds());
92222 /* The cast to a user pointer is valid due to the set_fs() */
92223 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
92224 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
92225 set_fs(oldfs);
92226
92227 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
92228 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
92229 index 876fbe8..8bbea9f 100644
92230 --- a/net/atm/atm_misc.c
92231 +++ b/net/atm/atm_misc.c
92232 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
92233 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
92234 return 1;
92235 atm_return(vcc, truesize);
92236 - atomic_inc(&vcc->stats->rx_drop);
92237 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92238 return 0;
92239 }
92240 EXPORT_SYMBOL(atm_charge);
92241 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
92242 }
92243 }
92244 atm_return(vcc, guess);
92245 - atomic_inc(&vcc->stats->rx_drop);
92246 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92247 return NULL;
92248 }
92249 EXPORT_SYMBOL(atm_alloc_charge);
92250 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
92251
92252 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92253 {
92254 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92255 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92256 __SONET_ITEMS
92257 #undef __HANDLE_ITEM
92258 }
92259 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
92260
92261 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92262 {
92263 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92264 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
92265 __SONET_ITEMS
92266 #undef __HANDLE_ITEM
92267 }
92268 diff --git a/net/atm/lec.h b/net/atm/lec.h
92269 index 4149db1..f2ab682 100644
92270 --- a/net/atm/lec.h
92271 +++ b/net/atm/lec.h
92272 @@ -48,7 +48,7 @@ struct lane2_ops {
92273 const u8 *tlvs, u32 sizeoftlvs);
92274 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
92275 const u8 *tlvs, u32 sizeoftlvs);
92276 -};
92277 +} __no_const;
92278
92279 /*
92280 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
92281 diff --git a/net/atm/proc.c b/net/atm/proc.c
92282 index bbb6461..cf04016 100644
92283 --- a/net/atm/proc.c
92284 +++ b/net/atm/proc.c
92285 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
92286 const struct k_atm_aal_stats *stats)
92287 {
92288 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
92289 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
92290 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
92291 - atomic_read(&stats->rx_drop));
92292 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
92293 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
92294 + atomic_read_unchecked(&stats->rx_drop));
92295 }
92296
92297 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
92298 diff --git a/net/atm/resources.c b/net/atm/resources.c
92299 index 0447d5d..3cf4728 100644
92300 --- a/net/atm/resources.c
92301 +++ b/net/atm/resources.c
92302 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
92303 static void copy_aal_stats(struct k_atm_aal_stats *from,
92304 struct atm_aal_stats *to)
92305 {
92306 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92307 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92308 __AAL_STAT_ITEMS
92309 #undef __HANDLE_ITEM
92310 }
92311 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
92312 static void subtract_aal_stats(struct k_atm_aal_stats *from,
92313 struct atm_aal_stats *to)
92314 {
92315 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92316 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
92317 __AAL_STAT_ITEMS
92318 #undef __HANDLE_ITEM
92319 }
92320 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
92321 index d5744b7..506bae3 100644
92322 --- a/net/ax25/sysctl_net_ax25.c
92323 +++ b/net/ax25/sysctl_net_ax25.c
92324 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
92325 {
92326 char path[sizeof("net/ax25/") + IFNAMSIZ];
92327 int k;
92328 - struct ctl_table *table;
92329 + ctl_table_no_const *table;
92330
92331 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
92332 if (!table)
92333 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
92334 index f680ee1..97e3542 100644
92335 --- a/net/batman-adv/bat_iv_ogm.c
92336 +++ b/net/batman-adv/bat_iv_ogm.c
92337 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
92338
92339 /* randomize initial seqno to avoid collision */
92340 get_random_bytes(&random_seqno, sizeof(random_seqno));
92341 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92342 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92343
92344 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
92345 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
92346 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
92347 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
92348
92349 /* change sequence number to network order */
92350 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
92351 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
92352 batadv_ogm_packet->seqno = htonl(seqno);
92353 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
92354 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
92355
92356 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
92357 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
92358 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
92359 return;
92360
92361 /* could be changed by schedule_own_packet() */
92362 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
92363 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
92364
92365 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
92366 has_directlink_flag = 1;
92367 diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
92368 index de27b31..7058bfe 100644
92369 --- a/net/batman-adv/bridge_loop_avoidance.c
92370 +++ b/net/batman-adv/bridge_loop_avoidance.c
92371 @@ -1522,6 +1522,8 @@ out:
92372 * in these cases, the skb is further handled by this function and
92373 * returns 1, otherwise it returns 0 and the caller shall further
92374 * process the skb.
92375 + *
92376 + * This call might reallocate skb data.
92377 */
92378 int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)
92379 {
92380 diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
92381 index f105219..7614af3 100644
92382 --- a/net/batman-adv/gateway_client.c
92383 +++ b/net/batman-adv/gateway_client.c
92384 @@ -508,6 +508,7 @@ out:
92385 return 0;
92386 }
92387
92388 +/* this call might reallocate skb data */
92389 static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
92390 {
92391 int ret = false;
92392 @@ -568,6 +569,7 @@ out:
92393 return ret;
92394 }
92395
92396 +/* this call might reallocate skb data */
92397 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
92398 {
92399 struct ethhdr *ethhdr;
92400 @@ -619,6 +621,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
92401
92402 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
92403 return false;
92404 +
92405 + /* skb->data might have been reallocated by pskb_may_pull() */
92406 + ethhdr = (struct ethhdr *)skb->data;
92407 + if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
92408 + ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN);
92409 +
92410 udphdr = (struct udphdr *)(skb->data + *header_len);
92411 *header_len += sizeof(*udphdr);
92412
92413 @@ -634,12 +642,14 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
92414 return true;
92415 }
92416
92417 +/* this call might reallocate skb data */
92418 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
92419 - struct sk_buff *skb, struct ethhdr *ethhdr)
92420 + struct sk_buff *skb)
92421 {
92422 struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
92423 struct batadv_orig_node *orig_dst_node = NULL;
92424 struct batadv_gw_node *curr_gw = NULL;
92425 + struct ethhdr *ethhdr;
92426 bool ret, out_of_range = false;
92427 unsigned int header_len = 0;
92428 uint8_t curr_tq_avg;
92429 @@ -648,6 +658,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
92430 if (!ret)
92431 goto out;
92432
92433 + ethhdr = (struct ethhdr *)skb->data;
92434 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
92435 ethhdr->h_dest);
92436 if (!orig_dst_node)
92437 diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
92438 index 039902d..1037d75 100644
92439 --- a/net/batman-adv/gateway_client.h
92440 +++ b/net/batman-adv/gateway_client.h
92441 @@ -34,7 +34,6 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
92442 void batadv_gw_node_purge(struct batadv_priv *bat_priv);
92443 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
92444 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
92445 -bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
92446 - struct sk_buff *skb, struct ethhdr *ethhdr);
92447 +bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
92448
92449 #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
92450 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
92451 index 522243a..b48c0ef 100644
92452 --- a/net/batman-adv/hard-interface.c
92453 +++ b/net/batman-adv/hard-interface.c
92454 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
92455 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
92456 dev_add_pack(&hard_iface->batman_adv_ptype);
92457
92458 - atomic_set(&hard_iface->frag_seqno, 1);
92459 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
92460 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
92461 hard_iface->net_dev->name);
92462
92463 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
92464 /* This can't be called via a bat_priv callback because
92465 * we have no bat_priv yet.
92466 */
92467 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
92468 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
92469 hard_iface->bat_iv.ogm_buff = NULL;
92470
92471 return hard_iface;
92472 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
92473 index 819dfb0..226bacd 100644
92474 --- a/net/batman-adv/soft-interface.c
92475 +++ b/net/batman-adv/soft-interface.c
92476 @@ -180,6 +180,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
92477 if (batadv_bla_tx(bat_priv, skb, vid))
92478 goto dropped;
92479
92480 + /* skb->data might have been reallocated by batadv_bla_tx() */
92481 + ethhdr = (struct ethhdr *)skb->data;
92482 +
92483 /* Register the client MAC in the transtable */
92484 if (!is_multicast_ether_addr(ethhdr->h_source))
92485 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
92486 @@ -220,6 +223,10 @@ static int batadv_interface_tx(struct sk_buff *skb,
92487 default:
92488 break;
92489 }
92490 +
92491 + /* reminder: ethhdr might have become unusable from here on
92492 + * (batadv_gw_is_dhcp_target() might have reallocated skb data)
92493 + */
92494 }
92495
92496 /* ethernet packet should be broadcasted */
92497 @@ -253,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
92498 primary_if->net_dev->dev_addr, ETH_ALEN);
92499
92500 /* set broadcast sequence number */
92501 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
92502 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
92503 bcast_packet->seqno = htonl(seqno);
92504
92505 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
92506 @@ -266,7 +273,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
92507 /* unicast packet */
92508 } else {
92509 if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) {
92510 - ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
92511 + ret = batadv_gw_out_of_range(bat_priv, skb);
92512 if (ret)
92513 goto dropped;
92514 }
92515 @@ -472,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
92516 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
92517
92518 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
92519 - atomic_set(&bat_priv->bcast_seqno, 1);
92520 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
92521 atomic_set(&bat_priv->tt.vn, 0);
92522 atomic_set(&bat_priv->tt.local_changes, 0);
92523 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
92524 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
92525 index aba8364..50fcbb8 100644
92526 --- a/net/batman-adv/types.h
92527 +++ b/net/batman-adv/types.h
92528 @@ -51,7 +51,7 @@
92529 struct batadv_hard_iface_bat_iv {
92530 unsigned char *ogm_buff;
92531 int ogm_buff_len;
92532 - atomic_t ogm_seqno;
92533 + atomic_unchecked_t ogm_seqno;
92534 };
92535
92536 /**
92537 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
92538 int16_t if_num;
92539 char if_status;
92540 struct net_device *net_dev;
92541 - atomic_t frag_seqno;
92542 + atomic_unchecked_t frag_seqno;
92543 struct kobject *hardif_obj;
92544 atomic_t refcount;
92545 struct packet_type batman_adv_ptype;
92546 @@ -558,7 +558,7 @@ struct batadv_priv {
92547 #ifdef CONFIG_BATMAN_ADV_DEBUG
92548 atomic_t log_level;
92549 #endif
92550 - atomic_t bcast_seqno;
92551 + atomic_unchecked_t bcast_seqno;
92552 atomic_t bcast_queue_left;
92553 atomic_t batman_queue_left;
92554 char num_ifaces;
92555 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
92556 index 0bb3b59..0e3052e 100644
92557 --- a/net/batman-adv/unicast.c
92558 +++ b/net/batman-adv/unicast.c
92559 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
92560 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
92561 frag2->flags = large_tail;
92562
92563 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
92564 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
92565 frag1->seqno = htons(seqno - 1);
92566 frag2->seqno = htons(seqno);
92567
92568 @@ -326,7 +326,9 @@ static bool batadv_unicast_push_and_fill_skb(struct sk_buff *skb, int hdr_size,
92569 * @skb: the skb containing the payload to encapsulate
92570 * @orig_node: the destination node
92571 *
92572 - * Returns false if the payload could not be encapsulated or true otherwise
92573 + * Returns false if the payload could not be encapsulated or true otherwise.
92574 + *
92575 + * This call might reallocate skb data.
92576 */
92577 static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
92578 struct batadv_orig_node *orig_node)
92579 @@ -343,7 +345,9 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
92580 * @orig_node: the destination node
92581 * @packet_subtype: the batman 4addr packet subtype to use
92582 *
92583 - * Returns false if the payload could not be encapsulated or true otherwise
92584 + * Returns false if the payload could not be encapsulated or true otherwise.
92585 + *
92586 + * This call might reallocate skb data.
92587 */
92588 bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv,
92589 struct sk_buff *skb,
92590 @@ -401,7 +405,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv,
92591 struct batadv_neigh_node *neigh_node;
92592 int data_len = skb->len;
92593 int ret = NET_RX_DROP;
92594 - unsigned int dev_mtu;
92595 + unsigned int dev_mtu, header_len;
92596
92597 /* get routing information */
92598 if (is_multicast_ether_addr(ethhdr->h_dest)) {
92599 @@ -429,10 +433,12 @@ find_router:
92600 switch (packet_type) {
92601 case BATADV_UNICAST:
92602 batadv_unicast_prepare_skb(skb, orig_node);
92603 + header_len = sizeof(struct batadv_unicast_packet);
92604 break;
92605 case BATADV_UNICAST_4ADDR:
92606 batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
92607 packet_subtype);
92608 + header_len = sizeof(struct batadv_unicast_4addr_packet);
92609 break;
92610 default:
92611 /* this function supports UNICAST and UNICAST_4ADDR only. It
92612 @@ -441,6 +447,7 @@ find_router:
92613 goto out;
92614 }
92615
92616 + ethhdr = (struct ethhdr *)(skb->data + header_len);
92617 unicast_packet = (struct batadv_unicast_packet *)skb->data;
92618
92619 /* inform the destination node that we are still missing a correct route
92620 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
92621 index ace5e55..a65a1c0 100644
92622 --- a/net/bluetooth/hci_core.c
92623 +++ b/net/bluetooth/hci_core.c
92624 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
92625 list_add(&hdev->list, &hci_dev_list);
92626 write_unlock(&hci_dev_list_lock);
92627
92628 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
92629 - WQ_MEM_RECLAIM, 1);
92630 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
92631 + WQ_MEM_RECLAIM, 1, hdev->name);
92632 if (!hdev->workqueue) {
92633 error = -ENOMEM;
92634 goto err;
92635 }
92636
92637 - hdev->req_workqueue = alloc_workqueue(hdev->name,
92638 + hdev->req_workqueue = alloc_workqueue("%s",
92639 WQ_HIGHPRI | WQ_UNBOUND |
92640 - WQ_MEM_RECLAIM, 1);
92641 + WQ_MEM_RECLAIM, 1, hdev->name);
92642 if (!hdev->req_workqueue) {
92643 destroy_workqueue(hdev->workqueue);
92644 error = -ENOMEM;
92645 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
92646 index 9bd7d95..6c4884f 100644
92647 --- a/net/bluetooth/hci_sock.c
92648 +++ b/net/bluetooth/hci_sock.c
92649 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
92650 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
92651 }
92652
92653 - len = min_t(unsigned int, len, sizeof(uf));
92654 + len = min((size_t)len, sizeof(uf));
92655 if (copy_from_user(&uf, optval, len)) {
92656 err = -EFAULT;
92657 break;
92658 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
92659 index 68843a2..30e9342 100644
92660 --- a/net/bluetooth/l2cap_core.c
92661 +++ b/net/bluetooth/l2cap_core.c
92662 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
92663 break;
92664
92665 case L2CAP_CONF_RFC:
92666 - if (olen == sizeof(rfc))
92667 - memcpy(&rfc, (void *)val, olen);
92668 + if (olen != sizeof(rfc))
92669 + break;
92670 +
92671 + memcpy(&rfc, (void *)val, olen);
92672
92673 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92674 rfc.mode != chan->mode)
92675 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92676 index 36fed40..be2eeb2 100644
92677 --- a/net/bluetooth/l2cap_sock.c
92678 +++ b/net/bluetooth/l2cap_sock.c
92679 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92680 struct sock *sk = sock->sk;
92681 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92682 struct l2cap_options opts;
92683 - int len, err = 0;
92684 + int err = 0;
92685 + size_t len = optlen;
92686 u32 opt;
92687
92688 BT_DBG("sk %p", sk);
92689 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92690 opts.max_tx = chan->max_tx;
92691 opts.txwin_size = chan->tx_win;
92692
92693 - len = min_t(unsigned int, sizeof(opts), optlen);
92694 + len = min(sizeof(opts), len);
92695 if (copy_from_user((char *) &opts, optval, len)) {
92696 err = -EFAULT;
92697 break;
92698 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92699 struct bt_security sec;
92700 struct bt_power pwr;
92701 struct l2cap_conn *conn;
92702 - int len, err = 0;
92703 + int err = 0;
92704 + size_t len = optlen;
92705 u32 opt;
92706
92707 BT_DBG("sk %p", sk);
92708 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92709
92710 sec.level = BT_SECURITY_LOW;
92711
92712 - len = min_t(unsigned int, sizeof(sec), optlen);
92713 + len = min(sizeof(sec), len);
92714 if (copy_from_user((char *) &sec, optval, len)) {
92715 err = -EFAULT;
92716 break;
92717 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92718
92719 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92720
92721 - len = min_t(unsigned int, sizeof(pwr), optlen);
92722 + len = min(sizeof(pwr), len);
92723 if (copy_from_user((char *) &pwr, optval, len)) {
92724 err = -EFAULT;
92725 break;
92726 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92727 index 30b3721..c1bd0a0 100644
92728 --- a/net/bluetooth/rfcomm/sock.c
92729 +++ b/net/bluetooth/rfcomm/sock.c
92730 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92731 struct sock *sk = sock->sk;
92732 struct bt_security sec;
92733 int err = 0;
92734 - size_t len;
92735 + size_t len = optlen;
92736 u32 opt;
92737
92738 BT_DBG("sk %p", sk);
92739 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92740
92741 sec.level = BT_SECURITY_LOW;
92742
92743 - len = min_t(unsigned int, sizeof(sec), optlen);
92744 + len = min(sizeof(sec), len);
92745 if (copy_from_user((char *) &sec, optval, len)) {
92746 err = -EFAULT;
92747 break;
92748 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92749 index b6e44ad..5b0d514 100644
92750 --- a/net/bluetooth/rfcomm/tty.c
92751 +++ b/net/bluetooth/rfcomm/tty.c
92752 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
92753 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
92754
92755 spin_lock_irqsave(&dev->port.lock, flags);
92756 - if (dev->port.count > 0) {
92757 + if (atomic_read(&dev->port.count) > 0) {
92758 spin_unlock_irqrestore(&dev->port.lock, flags);
92759 return;
92760 }
92761 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92762 return -ENODEV;
92763
92764 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92765 - dev->channel, dev->port.count);
92766 + dev->channel, atomic_read(&dev->port.count));
92767
92768 spin_lock_irqsave(&dev->port.lock, flags);
92769 - if (++dev->port.count > 1) {
92770 + if (atomic_inc_return(&dev->port.count) > 1) {
92771 spin_unlock_irqrestore(&dev->port.lock, flags);
92772 return 0;
92773 }
92774 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92775 return;
92776
92777 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92778 - dev->port.count);
92779 + atomic_read(&dev->port.count));
92780
92781 spin_lock_irqsave(&dev->port.lock, flags);
92782 - if (!--dev->port.count) {
92783 + if (!atomic_dec_return(&dev->port.count)) {
92784 spin_unlock_irqrestore(&dev->port.lock, flags);
92785 if (dev->tty_dev->parent)
92786 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
92787 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92788 index 3d110c4..4e1b2eb 100644
92789 --- a/net/bridge/netfilter/ebtables.c
92790 +++ b/net/bridge/netfilter/ebtables.c
92791 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92792 tmp.valid_hooks = t->table->valid_hooks;
92793 }
92794 mutex_unlock(&ebt_mutex);
92795 - if (copy_to_user(user, &tmp, *len) != 0){
92796 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92797 BUGPRINT("c2u Didn't work\n");
92798 ret = -EFAULT;
92799 break;
92800 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92801 goto out;
92802 tmp.valid_hooks = t->valid_hooks;
92803
92804 - if (copy_to_user(user, &tmp, *len) != 0) {
92805 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92806 ret = -EFAULT;
92807 break;
92808 }
92809 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92810 tmp.entries_size = t->table->entries_size;
92811 tmp.valid_hooks = t->table->valid_hooks;
92812
92813 - if (copy_to_user(user, &tmp, *len) != 0) {
92814 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92815 ret = -EFAULT;
92816 break;
92817 }
92818 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92819 index 2bd4b58..0dc30a1 100644
92820 --- a/net/caif/cfctrl.c
92821 +++ b/net/caif/cfctrl.c
92822 @@ -10,6 +10,7 @@
92823 #include <linux/spinlock.h>
92824 #include <linux/slab.h>
92825 #include <linux/pkt_sched.h>
92826 +#include <linux/sched.h>
92827 #include <net/caif/caif_layer.h>
92828 #include <net/caif/cfpkt.h>
92829 #include <net/caif/cfctrl.h>
92830 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92831 memset(&dev_info, 0, sizeof(dev_info));
92832 dev_info.id = 0xff;
92833 cfsrvl_init(&this->serv, 0, &dev_info, false);
92834 - atomic_set(&this->req_seq_no, 1);
92835 - atomic_set(&this->rsp_seq_no, 1);
92836 + atomic_set_unchecked(&this->req_seq_no, 1);
92837 + atomic_set_unchecked(&this->rsp_seq_no, 1);
92838 this->serv.layer.receive = cfctrl_recv;
92839 sprintf(this->serv.layer.name, "ctrl");
92840 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
92841 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
92842 struct cfctrl_request_info *req)
92843 {
92844 spin_lock_bh(&ctrl->info_list_lock);
92845 - atomic_inc(&ctrl->req_seq_no);
92846 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
92847 + atomic_inc_unchecked(&ctrl->req_seq_no);
92848 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
92849 list_add_tail(&req->list, &ctrl->list);
92850 spin_unlock_bh(&ctrl->info_list_lock);
92851 }
92852 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
92853 if (p != first)
92854 pr_warn("Requests are not received in order\n");
92855
92856 - atomic_set(&ctrl->rsp_seq_no,
92857 + atomic_set_unchecked(&ctrl->rsp_seq_no,
92858 p->sequence_no);
92859 list_del(&p->list);
92860 goto out;
92861 diff --git a/net/can/af_can.c b/net/can/af_can.c
92862 index c4e5085..aa9efdf 100644
92863 --- a/net/can/af_can.c
92864 +++ b/net/can/af_can.c
92865 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
92866 };
92867
92868 /* notifier block for netdevice event */
92869 -static struct notifier_block can_netdev_notifier __read_mostly = {
92870 +static struct notifier_block can_netdev_notifier = {
92871 .notifier_call = can_notifier,
92872 };
92873
92874 diff --git a/net/can/gw.c b/net/can/gw.c
92875 index 3ee690e..00d581b 100644
92876 --- a/net/can/gw.c
92877 +++ b/net/can/gw.c
92878 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
92879 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
92880
92881 static HLIST_HEAD(cgw_list);
92882 -static struct notifier_block notifier;
92883
92884 static struct kmem_cache *cgw_cache __read_mostly;
92885
92886 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
92887 return err;
92888 }
92889
92890 +static struct notifier_block notifier = {
92891 + .notifier_call = cgw_notifier
92892 +};
92893 +
92894 static __init int cgw_module_init(void)
92895 {
92896 /* sanitize given module parameter */
92897 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
92898 return -ENOMEM;
92899
92900 /* set notifier */
92901 - notifier.notifier_call = cgw_notifier;
92902 register_netdevice_notifier(&notifier);
92903
92904 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
92905 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
92906 index eb0a46a..5f3bae8 100644
92907 --- a/net/ceph/messenger.c
92908 +++ b/net/ceph/messenger.c
92909 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
92910 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
92911
92912 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
92913 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
92914 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
92915
92916 static struct page *zero_page; /* used in certain error cases */
92917
92918 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
92919 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
92920 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
92921
92922 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92923 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92924 s = addr_str[i];
92925
92926 switch (ss->ss_family) {
92927 diff --git a/net/compat.c b/net/compat.c
92928 index f0a1ba6..0541331 100644
92929 --- a/net/compat.c
92930 +++ b/net/compat.c
92931 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
92932 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
92933 __get_user(kmsg->msg_flags, &umsg->msg_flags))
92934 return -EFAULT;
92935 - kmsg->msg_name = compat_ptr(tmp1);
92936 - kmsg->msg_iov = compat_ptr(tmp2);
92937 - kmsg->msg_control = compat_ptr(tmp3);
92938 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
92939 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
92940 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
92941 return 0;
92942 }
92943
92944 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92945
92946 if (kern_msg->msg_namelen) {
92947 if (mode == VERIFY_READ) {
92948 - int err = move_addr_to_kernel(kern_msg->msg_name,
92949 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
92950 kern_msg->msg_namelen,
92951 kern_address);
92952 if (err < 0)
92953 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92954 kern_msg->msg_name = NULL;
92955
92956 tot_len = iov_from_user_compat_to_kern(kern_iov,
92957 - (struct compat_iovec __user *)kern_msg->msg_iov,
92958 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
92959 kern_msg->msg_iovlen);
92960 if (tot_len >= 0)
92961 kern_msg->msg_iov = kern_iov;
92962 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92963
92964 #define CMSG_COMPAT_FIRSTHDR(msg) \
92965 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
92966 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
92967 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
92968 (struct compat_cmsghdr __user *)NULL)
92969
92970 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
92971 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
92972 (ucmlen) <= (unsigned long) \
92973 ((mhdr)->msg_controllen - \
92974 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
92975 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
92976
92977 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
92978 struct compat_cmsghdr __user *cmsg, int cmsg_len)
92979 {
92980 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
92981 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
92982 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
92983 msg->msg_controllen)
92984 return NULL;
92985 return (struct compat_cmsghdr __user *)ptr;
92986 @@ -219,7 +219,7 @@ Efault:
92987
92988 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
92989 {
92990 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92991 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92992 struct compat_cmsghdr cmhdr;
92993 struct compat_timeval ctv;
92994 struct compat_timespec cts[3];
92995 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
92996
92997 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
92998 {
92999 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93000 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93001 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
93002 int fdnum = scm->fp->count;
93003 struct file **fp = scm->fp->fp;
93004 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
93005 return -EFAULT;
93006 old_fs = get_fs();
93007 set_fs(KERNEL_DS);
93008 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
93009 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
93010 set_fs(old_fs);
93011
93012 return err;
93013 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
93014 len = sizeof(ktime);
93015 old_fs = get_fs();
93016 set_fs(KERNEL_DS);
93017 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
93018 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
93019 set_fs(old_fs);
93020
93021 if (!err) {
93022 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93023 case MCAST_JOIN_GROUP:
93024 case MCAST_LEAVE_GROUP:
93025 {
93026 - struct compat_group_req __user *gr32 = (void *)optval;
93027 + struct compat_group_req __user *gr32 = (void __user *)optval;
93028 struct group_req __user *kgr =
93029 compat_alloc_user_space(sizeof(struct group_req));
93030 u32 interface;
93031 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93032 case MCAST_BLOCK_SOURCE:
93033 case MCAST_UNBLOCK_SOURCE:
93034 {
93035 - struct compat_group_source_req __user *gsr32 = (void *)optval;
93036 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
93037 struct group_source_req __user *kgsr = compat_alloc_user_space(
93038 sizeof(struct group_source_req));
93039 u32 interface;
93040 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93041 }
93042 case MCAST_MSFILTER:
93043 {
93044 - struct compat_group_filter __user *gf32 = (void *)optval;
93045 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93046 struct group_filter __user *kgf;
93047 u32 interface, fmode, numsrc;
93048
93049 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
93050 char __user *optval, int __user *optlen,
93051 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
93052 {
93053 - struct compat_group_filter __user *gf32 = (void *)optval;
93054 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93055 struct group_filter __user *kgf;
93056 int __user *koptlen;
93057 u32 interface, fmode, numsrc;
93058 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
93059
93060 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
93061 return -EINVAL;
93062 - if (copy_from_user(a, args, nas[call]))
93063 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
93064 return -EFAULT;
93065 a0 = a[0];
93066 a1 = a[1];
93067 diff --git a/net/core/datagram.c b/net/core/datagram.c
93068 index b71423d..0360434 100644
93069 --- a/net/core/datagram.c
93070 +++ b/net/core/datagram.c
93071 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
93072 }
93073
93074 kfree_skb(skb);
93075 - atomic_inc(&sk->sk_drops);
93076 + atomic_inc_unchecked(&sk->sk_drops);
93077 sk_mem_reclaim_partial(sk);
93078
93079 return err;
93080 diff --git a/net/core/dev.c b/net/core/dev.c
93081 index 7ddbb31..3902452 100644
93082 --- a/net/core/dev.c
93083 +++ b/net/core/dev.c
93084 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
93085 {
93086 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
93087 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
93088 - atomic_long_inc(&dev->rx_dropped);
93089 + atomic_long_inc_unchecked(&dev->rx_dropped);
93090 kfree_skb(skb);
93091 return NET_RX_DROP;
93092 }
93093 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
93094 skb_orphan(skb);
93095
93096 if (unlikely(!is_skb_forwardable(dev, skb))) {
93097 - atomic_long_inc(&dev->rx_dropped);
93098 + atomic_long_inc_unchecked(&dev->rx_dropped);
93099 kfree_skb(skb);
93100 return NET_RX_DROP;
93101 }
93102 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
93103
93104 struct dev_gso_cb {
93105 void (*destructor)(struct sk_buff *skb);
93106 -};
93107 +} __no_const;
93108
93109 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
93110
93111 @@ -3139,7 +3139,7 @@ enqueue:
93112
93113 local_irq_restore(flags);
93114
93115 - atomic_long_inc(&skb->dev->rx_dropped);
93116 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93117 kfree_skb(skb);
93118 return NET_RX_DROP;
93119 }
93120 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
93121 }
93122 EXPORT_SYMBOL(netif_rx_ni);
93123
93124 -static void net_tx_action(struct softirq_action *h)
93125 +static void net_tx_action(void)
93126 {
93127 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93128
93129 @@ -3545,7 +3545,7 @@ ncls:
93130 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
93131 } else {
93132 drop:
93133 - atomic_long_inc(&skb->dev->rx_dropped);
93134 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93135 kfree_skb(skb);
93136 /* Jamal, now you will not able to escape explaining
93137 * me how you were going to use this. :-)
93138 @@ -4153,7 +4153,7 @@ void netif_napi_del(struct napi_struct *napi)
93139 }
93140 EXPORT_SYMBOL(netif_napi_del);
93141
93142 -static void net_rx_action(struct softirq_action *h)
93143 +static void net_rx_action(void)
93144 {
93145 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93146 unsigned long time_limit = jiffies + 2;
93147 @@ -5590,7 +5590,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
93148 } else {
93149 netdev_stats_to_stats64(storage, &dev->stats);
93150 }
93151 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
93152 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
93153 return storage;
93154 }
93155 EXPORT_SYMBOL(dev_get_stats);
93156 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
93157 index 5b7d0e1..cb960fc 100644
93158 --- a/net/core/dev_ioctl.c
93159 +++ b/net/core/dev_ioctl.c
93160 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
93161 if (no_module && capable(CAP_NET_ADMIN))
93162 no_module = request_module("netdev-%s", name);
93163 if (no_module && capable(CAP_SYS_MODULE)) {
93164 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
93165 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
93166 +#else
93167 if (!request_module("%s", name))
93168 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
93169 name);
93170 +#endif
93171 }
93172 }
93173 EXPORT_SYMBOL(dev_load);
93174 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
93175 index ce91766..3b71cdb 100644
93176 --- a/net/core/ethtool.c
93177 +++ b/net/core/ethtool.c
93178 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
93179 if (ret)
93180 return ret;
93181
93182 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
93183 + len = min(tmp.len, dump.len);
93184 if (!len)
93185 return -EFAULT;
93186
93187 + /* Don't ever let the driver think there's more space available
93188 + * than it requested with .get_dump_flag().
93189 + */
93190 + dump.len = len;
93191 +
93192 + /* Always allocate enough space to hold the whole thing so that the
93193 + * driver does not need to check the length and bother with partial
93194 + * dumping.
93195 + */
93196 data = vzalloc(tmp.len);
93197 if (!data)
93198 return -ENOMEM;
93199 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
93200 if (ret)
93201 goto out;
93202
93203 + /* There are two sane possibilities:
93204 + * 1. The driver's .get_dump_data() does not touch dump.len.
93205 + * 2. Or it may set dump.len to how much it really writes, which
93206 + * should be tmp.len (or len if it can do a partial dump).
93207 + * In any case respond to userspace with the actual length of data
93208 + * it's receiving.
93209 + */
93210 + WARN_ON(dump.len != len && dump.len != tmp.len);
93211 + dump.len = len;
93212 +
93213 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
93214 ret = -EFAULT;
93215 goto out;
93216 diff --git a/net/core/flow.c b/net/core/flow.c
93217 index 7102f16..146b4bd 100644
93218 --- a/net/core/flow.c
93219 +++ b/net/core/flow.c
93220 @@ -61,7 +61,7 @@ struct flow_cache {
93221 struct timer_list rnd_timer;
93222 };
93223
93224 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
93225 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
93226 EXPORT_SYMBOL(flow_cache_genid);
93227 static struct flow_cache flow_cache_global;
93228 static struct kmem_cache *flow_cachep __read_mostly;
93229 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
93230
93231 static int flow_entry_valid(struct flow_cache_entry *fle)
93232 {
93233 - if (atomic_read(&flow_cache_genid) != fle->genid)
93234 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
93235 return 0;
93236 if (fle->object && !fle->object->ops->check(fle->object))
93237 return 0;
93238 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
93239 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
93240 fcp->hash_count++;
93241 }
93242 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
93243 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
93244 flo = fle->object;
93245 if (!flo)
93246 goto ret_object;
93247 @@ -279,7 +279,7 @@ nocache:
93248 }
93249 flo = resolver(net, key, family, dir, flo, ctx);
93250 if (fle) {
93251 - fle->genid = atomic_read(&flow_cache_genid);
93252 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
93253 if (!IS_ERR(flo))
93254 fle->object = flo;
93255 else
93256 diff --git a/net/core/iovec.c b/net/core/iovec.c
93257 index de178e4..1dabd8b 100644
93258 --- a/net/core/iovec.c
93259 +++ b/net/core/iovec.c
93260 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93261 if (m->msg_namelen) {
93262 if (mode == VERIFY_READ) {
93263 void __user *namep;
93264 - namep = (void __user __force *) m->msg_name;
93265 + namep = (void __force_user *) m->msg_name;
93266 err = move_addr_to_kernel(namep, m->msg_namelen,
93267 address);
93268 if (err < 0)
93269 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93270 }
93271
93272 size = m->msg_iovlen * sizeof(struct iovec);
93273 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
93274 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
93275 return -EFAULT;
93276
93277 m->msg_iov = iov;
93278 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
93279 index ce90b02..8752627 100644
93280 --- a/net/core/neighbour.c
93281 +++ b/net/core/neighbour.c
93282 @@ -2771,7 +2771,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
93283 size_t *lenp, loff_t *ppos)
93284 {
93285 int size, ret;
93286 - ctl_table tmp = *ctl;
93287 + ctl_table_no_const tmp = *ctl;
93288
93289 tmp.extra1 = &zero;
93290 tmp.extra2 = &unres_qlen_max;
93291 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
93292 index 569d355..79cf2d0 100644
93293 --- a/net/core/net-procfs.c
93294 +++ b/net/core/net-procfs.c
93295 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
93296 else
93297 seq_printf(seq, "%04x", ntohs(pt->type));
93298
93299 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93300 + seq_printf(seq, " %-8s %pf\n",
93301 + pt->dev ? pt->dev->name : "", NULL);
93302 +#else
93303 seq_printf(seq, " %-8s %pf\n",
93304 pt->dev ? pt->dev->name : "", pt->func);
93305 +#endif
93306 }
93307
93308 return 0;
93309 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
93310 index 981fed3..536af34 100644
93311 --- a/net/core/net-sysfs.c
93312 +++ b/net/core/net-sysfs.c
93313 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
93314 }
93315 EXPORT_SYMBOL(netdev_class_remove_file);
93316
93317 -int netdev_kobject_init(void)
93318 +int __init netdev_kobject_init(void)
93319 {
93320 kobj_ns_type_register(&net_ns_type_operations);
93321 return class_register(&net_class);
93322 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
93323 index f9765203..9feaef8 100644
93324 --- a/net/core/net_namespace.c
93325 +++ b/net/core/net_namespace.c
93326 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
93327 int error;
93328 LIST_HEAD(net_exit_list);
93329
93330 - list_add_tail(&ops->list, list);
93331 + pax_list_add_tail((struct list_head *)&ops->list, list);
93332 if (ops->init || (ops->id && ops->size)) {
93333 for_each_net(net) {
93334 error = ops_init(ops, net);
93335 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
93336
93337 out_undo:
93338 /* If I have an error cleanup all namespaces I initialized */
93339 - list_del(&ops->list);
93340 + pax_list_del((struct list_head *)&ops->list);
93341 ops_exit_list(ops, &net_exit_list);
93342 ops_free_list(ops, &net_exit_list);
93343 return error;
93344 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
93345 struct net *net;
93346 LIST_HEAD(net_exit_list);
93347
93348 - list_del(&ops->list);
93349 + pax_list_del((struct list_head *)&ops->list);
93350 for_each_net(net)
93351 list_add_tail(&net->exit_list, &net_exit_list);
93352 ops_exit_list(ops, &net_exit_list);
93353 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
93354 mutex_lock(&net_mutex);
93355 error = register_pernet_operations(&pernet_list, ops);
93356 if (!error && (first_device == &pernet_list))
93357 - first_device = &ops->list;
93358 + first_device = (struct list_head *)&ops->list;
93359 mutex_unlock(&net_mutex);
93360 return error;
93361 }
93362 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
93363 index cec074b..a53a938 100644
93364 --- a/net/core/netpoll.c
93365 +++ b/net/core/netpoll.c
93366 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93367 struct udphdr *udph;
93368 struct iphdr *iph;
93369 struct ethhdr *eth;
93370 - static atomic_t ip_ident;
93371 + static atomic_unchecked_t ip_ident;
93372 struct ipv6hdr *ip6h;
93373
93374 udp_len = len + sizeof(*udph);
93375 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93376 put_unaligned(0x45, (unsigned char *)iph);
93377 iph->tos = 0;
93378 put_unaligned(htons(ip_len), &(iph->tot_len));
93379 - iph->id = htons(atomic_inc_return(&ip_ident));
93380 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
93381 iph->frag_off = 0;
93382 iph->ttl = 64;
93383 iph->protocol = IPPROTO_UDP;
93384 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
93385 index a08bd2b..c59bd7c 100644
93386 --- a/net/core/rtnetlink.c
93387 +++ b/net/core/rtnetlink.c
93388 @@ -58,7 +58,7 @@ struct rtnl_link {
93389 rtnl_doit_func doit;
93390 rtnl_dumpit_func dumpit;
93391 rtnl_calcit_func calcit;
93392 -};
93393 +} __no_const;
93394
93395 static DEFINE_MUTEX(rtnl_mutex);
93396
93397 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
93398 if (rtnl_link_ops_get(ops->kind))
93399 return -EEXIST;
93400
93401 - if (!ops->dellink)
93402 - ops->dellink = unregister_netdevice_queue;
93403 + if (!ops->dellink) {
93404 + pax_open_kernel();
93405 + *(void **)&ops->dellink = unregister_netdevice_queue;
93406 + pax_close_kernel();
93407 + }
93408
93409 - list_add_tail(&ops->list, &link_ops);
93410 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
93411 return 0;
93412 }
93413 EXPORT_SYMBOL_GPL(__rtnl_link_register);
93414 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
93415 for_each_net(net) {
93416 __rtnl_kill_links(net, ops);
93417 }
93418 - list_del(&ops->list);
93419 + pax_list_del((struct list_head *)&ops->list);
93420 }
93421 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
93422
93423 @@ -2374,7 +2377,7 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
93424 struct nlattr *extfilt;
93425 u32 filter_mask = 0;
93426
93427 - extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct rtgenmsg),
93428 + extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
93429 IFLA_EXT_MASK);
93430 if (extfilt)
93431 filter_mask = nla_get_u32(extfilt);
93432 diff --git a/net/core/scm.c b/net/core/scm.c
93433 index 03795d0..98d6bdb 100644
93434 --- a/net/core/scm.c
93435 +++ b/net/core/scm.c
93436 @@ -54,7 +54,7 @@ static __inline__ int scm_check_creds(struct ucred *creds)
93437 return -EINVAL;
93438
93439 if ((creds->pid == task_tgid_vnr(current) ||
93440 - ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) &&
93441 + ns_capable(task_active_pid_ns(current)->user_ns, CAP_SYS_ADMIN)) &&
93442 ((uid_eq(uid, cred->uid) || uid_eq(uid, cred->euid) ||
93443 uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) &&
93444 ((gid_eq(gid, cred->gid) || gid_eq(gid, cred->egid) ||
93445 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
93446 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93447 {
93448 struct cmsghdr __user *cm
93449 - = (__force struct cmsghdr __user *)msg->msg_control;
93450 + = (struct cmsghdr __force_user *)msg->msg_control;
93451 struct cmsghdr cmhdr;
93452 int cmlen = CMSG_LEN(len);
93453 int err;
93454 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93455 err = -EFAULT;
93456 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
93457 goto out;
93458 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
93459 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
93460 goto out;
93461 cmlen = CMSG_SPACE(len);
93462 if (msg->msg_controllen < cmlen)
93463 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
93464 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93465 {
93466 struct cmsghdr __user *cm
93467 - = (__force struct cmsghdr __user*)msg->msg_control;
93468 + = (struct cmsghdr __force_user *)msg->msg_control;
93469
93470 int fdmax = 0;
93471 int fdnum = scm->fp->count;
93472 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93473 if (fdnum < fdmax)
93474 fdmax = fdnum;
93475
93476 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
93477 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
93478 i++, cmfptr++)
93479 {
93480 struct socket *sock;
93481 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
93482 index 1c1738c..4cab7f0 100644
93483 --- a/net/core/skbuff.c
93484 +++ b/net/core/skbuff.c
93485 @@ -3087,13 +3087,15 @@ void __init skb_init(void)
93486 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
93487 sizeof(struct sk_buff),
93488 0,
93489 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93490 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93491 + SLAB_NO_SANITIZE,
93492 NULL);
93493 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
93494 (2*sizeof(struct sk_buff)) +
93495 sizeof(atomic_t),
93496 0,
93497 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93498 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93499 + SLAB_NO_SANITIZE,
93500 NULL);
93501 }
93502
93503 diff --git a/net/core/sock.c b/net/core/sock.c
93504 index d6d024c..6ea7ab4 100644
93505 --- a/net/core/sock.c
93506 +++ b/net/core/sock.c
93507 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93508 struct sk_buff_head *list = &sk->sk_receive_queue;
93509
93510 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
93511 - atomic_inc(&sk->sk_drops);
93512 + atomic_inc_unchecked(&sk->sk_drops);
93513 trace_sock_rcvqueue_full(sk, skb);
93514 return -ENOMEM;
93515 }
93516 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93517 return err;
93518
93519 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
93520 - atomic_inc(&sk->sk_drops);
93521 + atomic_inc_unchecked(&sk->sk_drops);
93522 return -ENOBUFS;
93523 }
93524
93525 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93526 skb_dst_force(skb);
93527
93528 spin_lock_irqsave(&list->lock, flags);
93529 - skb->dropcount = atomic_read(&sk->sk_drops);
93530 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93531 __skb_queue_tail(list, skb);
93532 spin_unlock_irqrestore(&list->lock, flags);
93533
93534 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93535 skb->dev = NULL;
93536
93537 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
93538 - atomic_inc(&sk->sk_drops);
93539 + atomic_inc_unchecked(&sk->sk_drops);
93540 goto discard_and_relse;
93541 }
93542 if (nested)
93543 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93544 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
93545 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
93546 bh_unlock_sock(sk);
93547 - atomic_inc(&sk->sk_drops);
93548 + atomic_inc_unchecked(&sk->sk_drops);
93549 goto discard_and_relse;
93550 }
93551
93552 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93553 struct timeval tm;
93554 } v;
93555
93556 - int lv = sizeof(int);
93557 - int len;
93558 + unsigned int lv = sizeof(int);
93559 + unsigned int len;
93560
93561 if (get_user(len, optlen))
93562 return -EFAULT;
93563 - if (len < 0)
93564 + if (len > INT_MAX)
93565 return -EINVAL;
93566
93567 memset(&v, 0, sizeof(v));
93568 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93569
93570 case SO_PEERNAME:
93571 {
93572 - char address[128];
93573 + char address[_K_SS_MAXSIZE];
93574
93575 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
93576 return -ENOTCONN;
93577 - if (lv < len)
93578 + if (lv < len || sizeof address < len)
93579 return -EINVAL;
93580 if (copy_to_user(optval, address, len))
93581 return -EFAULT;
93582 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93583
93584 if (len > lv)
93585 len = lv;
93586 - if (copy_to_user(optval, &v, len))
93587 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
93588 return -EFAULT;
93589 lenout:
93590 if (put_user(len, optlen))
93591 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
93592 */
93593 smp_wmb();
93594 atomic_set(&sk->sk_refcnt, 1);
93595 - atomic_set(&sk->sk_drops, 0);
93596 + atomic_set_unchecked(&sk->sk_drops, 0);
93597 }
93598 EXPORT_SYMBOL(sock_init_data);
93599
93600 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
93601 index a0e9cf6..ef7f9ed 100644
93602 --- a/net/core/sock_diag.c
93603 +++ b/net/core/sock_diag.c
93604 @@ -9,26 +9,33 @@
93605 #include <linux/inet_diag.h>
93606 #include <linux/sock_diag.h>
93607
93608 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
93609 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
93610 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
93611 static DEFINE_MUTEX(sock_diag_table_mutex);
93612
93613 int sock_diag_check_cookie(void *sk, __u32 *cookie)
93614 {
93615 +#ifndef CONFIG_GRKERNSEC_HIDESYM
93616 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
93617 cookie[1] != INET_DIAG_NOCOOKIE) &&
93618 ((u32)(unsigned long)sk != cookie[0] ||
93619 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
93620 return -ESTALE;
93621 else
93622 +#endif
93623 return 0;
93624 }
93625 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
93626
93627 void sock_diag_save_cookie(void *sk, __u32 *cookie)
93628 {
93629 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93630 + cookie[0] = 0;
93631 + cookie[1] = 0;
93632 +#else
93633 cookie[0] = (u32)(unsigned long)sk;
93634 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
93635 +#endif
93636 }
93637 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
93638
93639 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
93640 mutex_lock(&sock_diag_table_mutex);
93641 if (sock_diag_handlers[hndl->family])
93642 err = -EBUSY;
93643 - else
93644 + else {
93645 + pax_open_kernel();
93646 sock_diag_handlers[hndl->family] = hndl;
93647 + pax_close_kernel();
93648 + }
93649 mutex_unlock(&sock_diag_table_mutex);
93650
93651 return err;
93652 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
93653
93654 mutex_lock(&sock_diag_table_mutex);
93655 BUG_ON(sock_diag_handlers[family] != hnld);
93656 + pax_open_kernel();
93657 sock_diag_handlers[family] = NULL;
93658 + pax_close_kernel();
93659 mutex_unlock(&sock_diag_table_mutex);
93660 }
93661 EXPORT_SYMBOL_GPL(sock_diag_unregister);
93662 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
93663 index cfdb46a..cef55e1 100644
93664 --- a/net/core/sysctl_net_core.c
93665 +++ b/net/core/sysctl_net_core.c
93666 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
93667 {
93668 unsigned int orig_size, size;
93669 int ret, i;
93670 - ctl_table tmp = {
93671 + ctl_table_no_const tmp = {
93672 .data = &size,
93673 .maxlen = sizeof(size),
93674 .mode = table->mode
93675 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
93676
93677 static __net_init int sysctl_core_net_init(struct net *net)
93678 {
93679 - struct ctl_table *tbl;
93680 + ctl_table_no_const *tbl = NULL;
93681
93682 net->core.sysctl_somaxconn = SOMAXCONN;
93683
93684 - tbl = netns_core_table;
93685 if (!net_eq(net, &init_net)) {
93686 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93687 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93688 if (tbl == NULL)
93689 goto err_dup;
93690
93691 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93692 if (net->user_ns != &init_user_ns) {
93693 tbl[0].procname = NULL;
93694 }
93695 - }
93696 -
93697 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93698 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93699 + } else
93700 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93701 if (net->core.sysctl_hdr == NULL)
93702 goto err_reg;
93703
93704 return 0;
93705
93706 err_reg:
93707 - if (tbl != netns_core_table)
93708 - kfree(tbl);
93709 + kfree(tbl);
93710 err_dup:
93711 return -ENOMEM;
93712 }
93713 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93714 kfree(tbl);
93715 }
93716
93717 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93718 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93719 .init = sysctl_core_net_init,
93720 .exit = sysctl_core_net_exit,
93721 };
93722 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93723 index c21f200..bc4565b 100644
93724 --- a/net/decnet/af_decnet.c
93725 +++ b/net/decnet/af_decnet.c
93726 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93727 .sysctl_rmem = sysctl_decnet_rmem,
93728 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93729 .obj_size = sizeof(struct dn_sock),
93730 + .slab_flags = SLAB_USERCOPY,
93731 };
93732
93733 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93734 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93735 index a55eecc..dd8428c 100644
93736 --- a/net/decnet/sysctl_net_decnet.c
93737 +++ b/net/decnet/sysctl_net_decnet.c
93738 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
93739
93740 if (len > *lenp) len = *lenp;
93741
93742 - if (copy_to_user(buffer, addr, len))
93743 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93744 return -EFAULT;
93745
93746 *lenp = len;
93747 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
93748
93749 if (len > *lenp) len = *lenp;
93750
93751 - if (copy_to_user(buffer, devname, len))
93752 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93753 return -EFAULT;
93754
93755 *lenp = len;
93756 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93757 index 55e1fd5..fd602b8 100644
93758 --- a/net/ieee802154/6lowpan.c
93759 +++ b/net/ieee802154/6lowpan.c
93760 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93761 hc06_ptr += 3;
93762 } else {
93763 /* compress nothing */
93764 - memcpy(hc06_ptr, &hdr, 4);
93765 + memcpy(hc06_ptr, hdr, 4);
93766 /* replace the top byte with new ECN | DSCP format */
93767 *hc06_ptr = tmp;
93768 hc06_ptr += 4;
93769 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93770 index d01be2a..8976537 100644
93771 --- a/net/ipv4/af_inet.c
93772 +++ b/net/ipv4/af_inet.c
93773 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
93774
93775 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93776
93777 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93778 - if (!sysctl_local_reserved_ports)
93779 - goto out;
93780 -
93781 rc = proto_register(&tcp_prot, 1);
93782 if (rc)
93783 - goto out_free_reserved_ports;
93784 + goto out;
93785
93786 rc = proto_register(&udp_prot, 1);
93787 if (rc)
93788 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
93789 proto_unregister(&udp_prot);
93790 out_unregister_tcp_proto:
93791 proto_unregister(&tcp_prot);
93792 -out_free_reserved_ports:
93793 - kfree(sysctl_local_reserved_ports);
93794 goto out;
93795 }
93796
93797 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
93798 index 2e7f194..0fa4d6d 100644
93799 --- a/net/ipv4/ah4.c
93800 +++ b/net/ipv4/ah4.c
93801 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
93802 return;
93803
93804 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
93805 - atomic_inc(&flow_cache_genid);
93806 + atomic_inc_unchecked(&flow_cache_genid);
93807 rt_genid_bump(net);
93808
93809 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
93810 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93811 index dfc39d4..0d4fa52 100644
93812 --- a/net/ipv4/devinet.c
93813 +++ b/net/ipv4/devinet.c
93814 @@ -771,7 +771,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
93815 ci = nla_data(tb[IFA_CACHEINFO]);
93816 if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) {
93817 err = -EINVAL;
93818 - goto errout;
93819 + goto errout_free;
93820 }
93821 *pvalid_lft = ci->ifa_valid;
93822 *pprefered_lft = ci->ifa_prefered;
93823 @@ -779,6 +779,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
93824
93825 return ifa;
93826
93827 +errout_free:
93828 + inet_free_ifa(ifa);
93829 errout:
93830 return ERR_PTR(err);
93831 }
93832 @@ -1529,7 +1531,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93833 idx = 0;
93834 head = &net->dev_index_head[h];
93835 rcu_read_lock();
93836 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93837 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93838 net->dev_base_seq;
93839 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93840 if (idx < s_idx)
93841 @@ -1840,7 +1842,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93842 idx = 0;
93843 head = &net->dev_index_head[h];
93844 rcu_read_lock();
93845 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93846 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93847 net->dev_base_seq;
93848 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93849 if (idx < s_idx)
93850 @@ -2065,7 +2067,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
93851 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93852 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93853
93854 -static struct devinet_sysctl_table {
93855 +static const struct devinet_sysctl_table {
93856 struct ctl_table_header *sysctl_header;
93857 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93858 } devinet_sysctl = {
93859 @@ -2183,7 +2185,7 @@ static __net_init int devinet_init_net(struct net *net)
93860 int err;
93861 struct ipv4_devconf *all, *dflt;
93862 #ifdef CONFIG_SYSCTL
93863 - struct ctl_table *tbl = ctl_forward_entry;
93864 + ctl_table_no_const *tbl = NULL;
93865 struct ctl_table_header *forw_hdr;
93866 #endif
93867
93868 @@ -2201,7 +2203,7 @@ static __net_init int devinet_init_net(struct net *net)
93869 goto err_alloc_dflt;
93870
93871 #ifdef CONFIG_SYSCTL
93872 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93873 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93874 if (tbl == NULL)
93875 goto err_alloc_ctl;
93876
93877 @@ -2221,7 +2223,10 @@ static __net_init int devinet_init_net(struct net *net)
93878 goto err_reg_dflt;
93879
93880 err = -ENOMEM;
93881 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93882 + if (!net_eq(net, &init_net))
93883 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93884 + else
93885 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93886 if (forw_hdr == NULL)
93887 goto err_reg_ctl;
93888 net->ipv4.forw_hdr = forw_hdr;
93889 @@ -2237,8 +2242,7 @@ err_reg_ctl:
93890 err_reg_dflt:
93891 __devinet_sysctl_unregister(all);
93892 err_reg_all:
93893 - if (tbl != ctl_forward_entry)
93894 - kfree(tbl);
93895 + kfree(tbl);
93896 err_alloc_ctl:
93897 #endif
93898 if (dflt != &ipv4_devconf_dflt)
93899 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
93900 index 4cfe34d..d2fac8a 100644
93901 --- a/net/ipv4/esp4.c
93902 +++ b/net/ipv4/esp4.c
93903 @@ -477,7 +477,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
93904 }
93905
93906 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
93907 - net_adj) & ~(align - 1)) + (net_adj - 2);
93908 + net_adj) & ~(align - 1)) + net_adj - 2;
93909 }
93910
93911 static void esp4_err(struct sk_buff *skb, u32 info)
93912 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
93913 return;
93914
93915 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
93916 - atomic_inc(&flow_cache_genid);
93917 + atomic_inc_unchecked(&flow_cache_genid);
93918 rt_genid_bump(net);
93919
93920 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
93921 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
93922 index c7629a2..b62d139 100644
93923 --- a/net/ipv4/fib_frontend.c
93924 +++ b/net/ipv4/fib_frontend.c
93925 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
93926 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93927 fib_sync_up(dev);
93928 #endif
93929 - atomic_inc(&net->ipv4.dev_addr_genid);
93930 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93931 rt_cache_flush(dev_net(dev));
93932 break;
93933 case NETDEV_DOWN:
93934 fib_del_ifaddr(ifa, NULL);
93935 - atomic_inc(&net->ipv4.dev_addr_genid);
93936 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93937 if (ifa->ifa_dev->ifa_list == NULL) {
93938 /* Last address was deleted from this interface.
93939 * Disable IP.
93940 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
93941 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93942 fib_sync_up(dev);
93943 #endif
93944 - atomic_inc(&net->ipv4.dev_addr_genid);
93945 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93946 rt_cache_flush(net);
93947 break;
93948 case NETDEV_DOWN:
93949 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
93950 index 8f6cb7a..34507f9 100644
93951 --- a/net/ipv4/fib_semantics.c
93952 +++ b/net/ipv4/fib_semantics.c
93953 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
93954 nh->nh_saddr = inet_select_addr(nh->nh_dev,
93955 nh->nh_gw,
93956 nh->nh_parent->fib_scope);
93957 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
93958 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
93959
93960 return nh->nh_saddr;
93961 }
93962 diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
93963 index 49616fe..6e8a13d 100644
93964 --- a/net/ipv4/fib_trie.c
93965 +++ b/net/ipv4/fib_trie.c
93966 @@ -71,7 +71,6 @@
93967 #include <linux/init.h>
93968 #include <linux/list.h>
93969 #include <linux/slab.h>
93970 -#include <linux/prefetch.h>
93971 #include <linux/export.h>
93972 #include <net/net_namespace.h>
93973 #include <net/ip.h>
93974 @@ -1761,10 +1760,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
93975 if (!c)
93976 continue;
93977
93978 - if (IS_LEAF(c)) {
93979 - prefetch(rcu_dereference_rtnl(p->child[idx]));
93980 + if (IS_LEAF(c))
93981 return (struct leaf *) c;
93982 - }
93983
93984 /* Rescan start scanning in new node */
93985 p = (struct tnode *) c;
93986 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
93987 index 6acb541..9ea617d 100644
93988 --- a/net/ipv4/inet_connection_sock.c
93989 +++ b/net/ipv4/inet_connection_sock.c
93990 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
93991 .range = { 32768, 61000 },
93992 };
93993
93994 -unsigned long *sysctl_local_reserved_ports;
93995 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
93996 EXPORT_SYMBOL(sysctl_local_reserved_ports);
93997
93998 void inet_get_local_port_range(int *low, int *high)
93999 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
94000 index 6af375a..c493c74 100644
94001 --- a/net/ipv4/inet_hashtables.c
94002 +++ b/net/ipv4/inet_hashtables.c
94003 @@ -18,12 +18,15 @@
94004 #include <linux/sched.h>
94005 #include <linux/slab.h>
94006 #include <linux/wait.h>
94007 +#include <linux/security.h>
94008
94009 #include <net/inet_connection_sock.h>
94010 #include <net/inet_hashtables.h>
94011 #include <net/secure_seq.h>
94012 #include <net/ip.h>
94013
94014 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
94015 +
94016 /*
94017 * Allocate and initialize a new local port bind bucket.
94018 * The bindhash mutex for snum's hash chain must be held here.
94019 @@ -554,6 +557,8 @@ ok:
94020 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
94021 spin_unlock(&head->lock);
94022
94023 + gr_update_task_in_ip_table(current, inet_sk(sk));
94024 +
94025 if (tw) {
94026 inet_twsk_deschedule(tw, death_row);
94027 while (twrefcnt) {
94028 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
94029 index 000e3d2..5472da3 100644
94030 --- a/net/ipv4/inetpeer.c
94031 +++ b/net/ipv4/inetpeer.c
94032 @@ -503,8 +503,8 @@ relookup:
94033 if (p) {
94034 p->daddr = *daddr;
94035 atomic_set(&p->refcnt, 1);
94036 - atomic_set(&p->rid, 0);
94037 - atomic_set(&p->ip_id_count,
94038 + atomic_set_unchecked(&p->rid, 0);
94039 + atomic_set_unchecked(&p->ip_id_count,
94040 (daddr->family == AF_INET) ?
94041 secure_ip_id(daddr->addr.a4) :
94042 secure_ipv6_id(daddr->addr.a6));
94043 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
94044 index b66910a..cfe416e 100644
94045 --- a/net/ipv4/ip_fragment.c
94046 +++ b/net/ipv4/ip_fragment.c
94047 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
94048 return 0;
94049
94050 start = qp->rid;
94051 - end = atomic_inc_return(&peer->rid);
94052 + end = atomic_inc_return_unchecked(&peer->rid);
94053 qp->rid = end;
94054
94055 rc = qp->q.fragments && (end - start) > max;
94056 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
94057
94058 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94059 {
94060 - struct ctl_table *table;
94061 + ctl_table_no_const *table = NULL;
94062 struct ctl_table_header *hdr;
94063
94064 - table = ip4_frags_ns_ctl_table;
94065 if (!net_eq(net, &init_net)) {
94066 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94067 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94068 if (table == NULL)
94069 goto err_alloc;
94070
94071 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94072 /* Don't export sysctls to unprivileged users */
94073 if (net->user_ns != &init_user_ns)
94074 table[0].procname = NULL;
94075 - }
94076 + hdr = register_net_sysctl(net, "net/ipv4", table);
94077 + } else
94078 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
94079
94080 - hdr = register_net_sysctl(net, "net/ipv4", table);
94081 if (hdr == NULL)
94082 goto err_reg;
94083
94084 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94085 return 0;
94086
94087 err_reg:
94088 - if (!net_eq(net, &init_net))
94089 - kfree(table);
94090 + kfree(table);
94091 err_alloc:
94092 return -ENOMEM;
94093 }
94094 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
94095 index 855004f..9644112 100644
94096 --- a/net/ipv4/ip_gre.c
94097 +++ b/net/ipv4/ip_gre.c
94098 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
94099 module_param(log_ecn_error, bool, 0644);
94100 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94101
94102 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
94103 +static struct rtnl_link_ops ipgre_link_ops;
94104 static int ipgre_tunnel_init(struct net_device *dev);
94105
94106 static int ipgre_net_id __read_mostly;
94107 @@ -572,7 +572,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
94108 if (daddr)
94109 memcpy(&iph->daddr, daddr, 4);
94110 if (iph->daddr)
94111 - return t->hlen;
94112 + return t->hlen + sizeof(*iph);
94113
94114 return -(t->hlen + sizeof(*iph));
94115 }
94116 @@ -919,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
94117 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
94118 };
94119
94120 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94121 +static struct rtnl_link_ops ipgre_link_ops = {
94122 .kind = "gre",
94123 .maxtype = IFLA_GRE_MAX,
94124 .policy = ipgre_policy,
94125 @@ -933,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94126 .fill_info = ipgre_fill_info,
94127 };
94128
94129 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
94130 +static struct rtnl_link_ops ipgre_tap_ops = {
94131 .kind = "gretap",
94132 .maxtype = IFLA_GRE_MAX,
94133 .policy = ipgre_policy,
94134 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
94135 index d9c4f11..02b82dbc 100644
94136 --- a/net/ipv4/ip_sockglue.c
94137 +++ b/net/ipv4/ip_sockglue.c
94138 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94139 len = min_t(unsigned int, len, opt->optlen);
94140 if (put_user(len, optlen))
94141 return -EFAULT;
94142 - if (copy_to_user(optval, opt->__data, len))
94143 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
94144 + copy_to_user(optval, opt->__data, len))
94145 return -EFAULT;
94146 return 0;
94147 }
94148 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94149 if (sk->sk_type != SOCK_STREAM)
94150 return -ENOPROTOOPT;
94151
94152 - msg.msg_control = optval;
94153 + msg.msg_control = (void __force_kernel *)optval;
94154 msg.msg_controllen = len;
94155 msg.msg_flags = flags;
94156
94157 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
94158 index 17cc0ff..63856c4 100644
94159 --- a/net/ipv4/ip_vti.c
94160 +++ b/net/ipv4/ip_vti.c
94161 @@ -47,7 +47,7 @@
94162 #define HASH_SIZE 16
94163 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
94164
94165 -static struct rtnl_link_ops vti_link_ops __read_mostly;
94166 +static struct rtnl_link_ops vti_link_ops;
94167
94168 static int vti_net_id __read_mostly;
94169 struct vti_net {
94170 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
94171 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
94172 };
94173
94174 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
94175 +static struct rtnl_link_ops vti_link_ops = {
94176 .kind = "vti",
94177 .maxtype = IFLA_VTI_MAX,
94178 .policy = vti_policy,
94179 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
94180 index 59cb8c7..a72160c 100644
94181 --- a/net/ipv4/ipcomp.c
94182 +++ b/net/ipv4/ipcomp.c
94183 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
94184 return;
94185
94186 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
94187 - atomic_inc(&flow_cache_genid);
94188 + atomic_inc_unchecked(&flow_cache_genid);
94189 rt_genid_bump(net);
94190
94191 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
94192 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
94193 index efa1138..20dbba0 100644
94194 --- a/net/ipv4/ipconfig.c
94195 +++ b/net/ipv4/ipconfig.c
94196 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
94197
94198 mm_segment_t oldfs = get_fs();
94199 set_fs(get_ds());
94200 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94201 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94202 set_fs(oldfs);
94203 return res;
94204 }
94205 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
94206
94207 mm_segment_t oldfs = get_fs();
94208 set_fs(get_ds());
94209 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94210 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94211 set_fs(oldfs);
94212 return res;
94213 }
94214 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
94215
94216 mm_segment_t oldfs = get_fs();
94217 set_fs(get_ds());
94218 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
94219 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
94220 set_fs(oldfs);
94221 return res;
94222 }
94223 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
94224 index 7cfc456..e726868 100644
94225 --- a/net/ipv4/ipip.c
94226 +++ b/net/ipv4/ipip.c
94227 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94228 static int ipip_net_id __read_mostly;
94229
94230 static int ipip_tunnel_init(struct net_device *dev);
94231 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
94232 +static struct rtnl_link_ops ipip_link_ops;
94233
94234 static int ipip_err(struct sk_buff *skb, u32 info)
94235 {
94236 @@ -406,7 +406,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
94237 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
94238 };
94239
94240 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
94241 +static struct rtnl_link_ops ipip_link_ops = {
94242 .kind = "ipip",
94243 .maxtype = IFLA_IPTUN_MAX,
94244 .policy = ipip_policy,
94245 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
94246 index 85a4f21..1beb1f5 100644
94247 --- a/net/ipv4/netfilter/arp_tables.c
94248 +++ b/net/ipv4/netfilter/arp_tables.c
94249 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
94250 #endif
94251
94252 static int get_info(struct net *net, void __user *user,
94253 - const int *len, int compat)
94254 + int len, int compat)
94255 {
94256 char name[XT_TABLE_MAXNAMELEN];
94257 struct xt_table *t;
94258 int ret;
94259
94260 - if (*len != sizeof(struct arpt_getinfo)) {
94261 - duprintf("length %u != %Zu\n", *len,
94262 + if (len != sizeof(struct arpt_getinfo)) {
94263 + duprintf("length %u != %Zu\n", len,
94264 sizeof(struct arpt_getinfo));
94265 return -EINVAL;
94266 }
94267 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
94268 info.size = private->size;
94269 strcpy(info.name, name);
94270
94271 - if (copy_to_user(user, &info, *len) != 0)
94272 + if (copy_to_user(user, &info, len) != 0)
94273 ret = -EFAULT;
94274 else
94275 ret = 0;
94276 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
94277
94278 switch (cmd) {
94279 case ARPT_SO_GET_INFO:
94280 - ret = get_info(sock_net(sk), user, len, 1);
94281 + ret = get_info(sock_net(sk), user, *len, 1);
94282 break;
94283 case ARPT_SO_GET_ENTRIES:
94284 ret = compat_get_entries(sock_net(sk), user, len);
94285 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
94286
94287 switch (cmd) {
94288 case ARPT_SO_GET_INFO:
94289 - ret = get_info(sock_net(sk), user, len, 0);
94290 + ret = get_info(sock_net(sk), user, *len, 0);
94291 break;
94292
94293 case ARPT_SO_GET_ENTRIES:
94294 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
94295 index d23118d..6ad7277 100644
94296 --- a/net/ipv4/netfilter/ip_tables.c
94297 +++ b/net/ipv4/netfilter/ip_tables.c
94298 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
94299 #endif
94300
94301 static int get_info(struct net *net, void __user *user,
94302 - const int *len, int compat)
94303 + int len, int compat)
94304 {
94305 char name[XT_TABLE_MAXNAMELEN];
94306 struct xt_table *t;
94307 int ret;
94308
94309 - if (*len != sizeof(struct ipt_getinfo)) {
94310 - duprintf("length %u != %zu\n", *len,
94311 + if (len != sizeof(struct ipt_getinfo)) {
94312 + duprintf("length %u != %zu\n", len,
94313 sizeof(struct ipt_getinfo));
94314 return -EINVAL;
94315 }
94316 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
94317 info.size = private->size;
94318 strcpy(info.name, name);
94319
94320 - if (copy_to_user(user, &info, *len) != 0)
94321 + if (copy_to_user(user, &info, len) != 0)
94322 ret = -EFAULT;
94323 else
94324 ret = 0;
94325 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94326
94327 switch (cmd) {
94328 case IPT_SO_GET_INFO:
94329 - ret = get_info(sock_net(sk), user, len, 1);
94330 + ret = get_info(sock_net(sk), user, *len, 1);
94331 break;
94332 case IPT_SO_GET_ENTRIES:
94333 ret = compat_get_entries(sock_net(sk), user, len);
94334 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94335
94336 switch (cmd) {
94337 case IPT_SO_GET_INFO:
94338 - ret = get_info(sock_net(sk), user, len, 0);
94339 + ret = get_info(sock_net(sk), user, *len, 0);
94340 break;
94341
94342 case IPT_SO_GET_ENTRIES:
94343 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
94344 index 7d93d62..cbbf2a3 100644
94345 --- a/net/ipv4/ping.c
94346 +++ b/net/ipv4/ping.c
94347 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
94348 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94349 0, sock_i_ino(sp),
94350 atomic_read(&sp->sk_refcnt), sp,
94351 - atomic_read(&sp->sk_drops), len);
94352 + atomic_read_unchecked(&sp->sk_drops), len);
94353 }
94354
94355 static int ping_seq_show(struct seq_file *seq, void *v)
94356 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
94357 index dd44e0a..06dcca4 100644
94358 --- a/net/ipv4/raw.c
94359 +++ b/net/ipv4/raw.c
94360 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
94361 int raw_rcv(struct sock *sk, struct sk_buff *skb)
94362 {
94363 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
94364 - atomic_inc(&sk->sk_drops);
94365 + atomic_inc_unchecked(&sk->sk_drops);
94366 kfree_skb(skb);
94367 return NET_RX_DROP;
94368 }
94369 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
94370
94371 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
94372 {
94373 + struct icmp_filter filter;
94374 +
94375 if (optlen > sizeof(struct icmp_filter))
94376 optlen = sizeof(struct icmp_filter);
94377 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
94378 + if (copy_from_user(&filter, optval, optlen))
94379 return -EFAULT;
94380 + raw_sk(sk)->filter = filter;
94381 return 0;
94382 }
94383
94384 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
94385 {
94386 int len, ret = -EFAULT;
94387 + struct icmp_filter filter;
94388
94389 if (get_user(len, optlen))
94390 goto out;
94391 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
94392 if (len > sizeof(struct icmp_filter))
94393 len = sizeof(struct icmp_filter);
94394 ret = -EFAULT;
94395 - if (put_user(len, optlen) ||
94396 - copy_to_user(optval, &raw_sk(sk)->filter, len))
94397 + filter = raw_sk(sk)->filter;
94398 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
94399 goto out;
94400 ret = 0;
94401 out: return ret;
94402 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
94403 0, 0L, 0,
94404 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
94405 0, sock_i_ino(sp),
94406 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
94407 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
94408 }
94409
94410 static int raw_seq_show(struct seq_file *seq, void *v)
94411 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
94412 index d35bbf0..faa3ab8 100644
94413 --- a/net/ipv4/route.c
94414 +++ b/net/ipv4/route.c
94415 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
94416 .maxlen = sizeof(int),
94417 .mode = 0200,
94418 .proc_handler = ipv4_sysctl_rtcache_flush,
94419 + .extra1 = &init_net,
94420 },
94421 { },
94422 };
94423
94424 static __net_init int sysctl_route_net_init(struct net *net)
94425 {
94426 - struct ctl_table *tbl;
94427 + ctl_table_no_const *tbl = NULL;
94428
94429 - tbl = ipv4_route_flush_table;
94430 if (!net_eq(net, &init_net)) {
94431 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94432 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94433 if (tbl == NULL)
94434 goto err_dup;
94435
94436 /* Don't export sysctls to unprivileged users */
94437 if (net->user_ns != &init_user_ns)
94438 tbl[0].procname = NULL;
94439 - }
94440 - tbl[0].extra1 = net;
94441 + tbl[0].extra1 = net;
94442 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94443 + } else
94444 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
94445
94446 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94447 if (net->ipv4.route_hdr == NULL)
94448 goto err_reg;
94449 return 0;
94450
94451 err_reg:
94452 - if (tbl != ipv4_route_flush_table)
94453 - kfree(tbl);
94454 + kfree(tbl);
94455 err_dup:
94456 return -ENOMEM;
94457 }
94458 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
94459
94460 static __net_init int rt_genid_init(struct net *net)
94461 {
94462 - atomic_set(&net->rt_genid, 0);
94463 + atomic_set_unchecked(&net->rt_genid, 0);
94464 get_random_bytes(&net->ipv4.dev_addr_genid,
94465 sizeof(net->ipv4.dev_addr_genid));
94466 return 0;
94467 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
94468 index 3f25e75..3ae0f4d 100644
94469 --- a/net/ipv4/sysctl_net_ipv4.c
94470 +++ b/net/ipv4/sysctl_net_ipv4.c
94471 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
94472 {
94473 int ret;
94474 int range[2];
94475 - ctl_table tmp = {
94476 + ctl_table_no_const tmp = {
94477 .data = &range,
94478 .maxlen = sizeof(range),
94479 .mode = table->mode,
94480 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
94481 int ret;
94482 gid_t urange[2];
94483 kgid_t low, high;
94484 - ctl_table tmp = {
94485 + ctl_table_no_const tmp = {
94486 .data = &urange,
94487 .maxlen = sizeof(urange),
94488 .mode = table->mode,
94489 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
94490 void __user *buffer, size_t *lenp, loff_t *ppos)
94491 {
94492 char val[TCP_CA_NAME_MAX];
94493 - ctl_table tbl = {
94494 + ctl_table_no_const tbl = {
94495 .data = val,
94496 .maxlen = TCP_CA_NAME_MAX,
94497 };
94498 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
94499 void __user *buffer, size_t *lenp,
94500 loff_t *ppos)
94501 {
94502 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
94503 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
94504 int ret;
94505
94506 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94507 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
94508 void __user *buffer, size_t *lenp,
94509 loff_t *ppos)
94510 {
94511 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
94512 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
94513 int ret;
94514
94515 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94516 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
94517 struct mem_cgroup *memcg;
94518 #endif
94519
94520 - ctl_table tmp = {
94521 + ctl_table_no_const tmp = {
94522 .data = &vec,
94523 .maxlen = sizeof(vec),
94524 .mode = ctl->mode,
94525 };
94526
94527 if (!write) {
94528 - ctl->data = &net->ipv4.sysctl_tcp_mem;
94529 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
94530 + ctl_table_no_const tcp_mem = *ctl;
94531 +
94532 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
94533 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
94534 }
94535
94536 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
94537 @@ -238,7 +240,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
94538 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
94539 size_t *lenp, loff_t *ppos)
94540 {
94541 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94542 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94543 struct tcp_fastopen_context *ctxt;
94544 int ret;
94545 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
94546 @@ -481,7 +483,7 @@ static struct ctl_table ipv4_table[] = {
94547 },
94548 {
94549 .procname = "ip_local_reserved_ports",
94550 - .data = NULL, /* initialized in sysctl_ipv4_init */
94551 + .data = sysctl_local_reserved_ports,
94552 .maxlen = 65536,
94553 .mode = 0644,
94554 .proc_handler = proc_do_large_bitmap,
94555 @@ -846,11 +848,10 @@ static struct ctl_table ipv4_net_table[] = {
94556
94557 static __net_init int ipv4_sysctl_init_net(struct net *net)
94558 {
94559 - struct ctl_table *table;
94560 + ctl_table_no_const *table = NULL;
94561
94562 - table = ipv4_net_table;
94563 if (!net_eq(net, &init_net)) {
94564 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
94565 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
94566 if (table == NULL)
94567 goto err_alloc;
94568
94569 @@ -885,15 +886,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
94570
94571 tcp_init_mem(net);
94572
94573 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94574 + if (!net_eq(net, &init_net))
94575 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94576 + else
94577 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
94578 if (net->ipv4.ipv4_hdr == NULL)
94579 goto err_reg;
94580
94581 return 0;
94582
94583 err_reg:
94584 - if (!net_eq(net, &init_net))
94585 - kfree(table);
94586 + kfree(table);
94587 err_alloc:
94588 return -ENOMEM;
94589 }
94590 @@ -915,16 +918,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
94591 static __init int sysctl_ipv4_init(void)
94592 {
94593 struct ctl_table_header *hdr;
94594 - struct ctl_table *i;
94595 -
94596 - for (i = ipv4_table; i->procname; i++) {
94597 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
94598 - i->data = sysctl_local_reserved_ports;
94599 - break;
94600 - }
94601 - }
94602 - if (!i->procname)
94603 - return -EINVAL;
94604
94605 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
94606 if (hdr == NULL)
94607 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
94608 index 9c62257..651cc27 100644
94609 --- a/net/ipv4/tcp_input.c
94610 +++ b/net/ipv4/tcp_input.c
94611 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
94612 * simplifies code)
94613 */
94614 static void
94615 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94616 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94617 struct sk_buff *head, struct sk_buff *tail,
94618 u32 start, u32 end)
94619 {
94620 @@ -5522,6 +5522,7 @@ discard:
94621 tcp_paws_reject(&tp->rx_opt, 0))
94622 goto discard_and_undo;
94623
94624 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
94625 if (th->syn) {
94626 /* We see SYN without ACK. It is attempt of
94627 * simultaneous connect with crossed SYNs.
94628 @@ -5572,6 +5573,7 @@ discard:
94629 goto discard;
94630 #endif
94631 }
94632 +#endif
94633 /* "fifth, if neither of the SYN or RST bits is set then
94634 * drop the segment and return."
94635 */
94636 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94637 goto discard;
94638
94639 if (th->syn) {
94640 - if (th->fin)
94641 + if (th->fin || th->urg || th->psh)
94642 goto discard;
94643 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94644 return 1;
94645 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94646 index 7999fc5..c812f42 100644
94647 --- a/net/ipv4/tcp_ipv4.c
94648 +++ b/net/ipv4/tcp_ipv4.c
94649 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
94650 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94651
94652
94653 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94654 +extern int grsec_enable_blackhole;
94655 +#endif
94656 +
94657 #ifdef CONFIG_TCP_MD5SIG
94658 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94659 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94660 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94661 return 0;
94662
94663 reset:
94664 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94665 + if (!grsec_enable_blackhole)
94666 +#endif
94667 tcp_v4_send_reset(rsk, skb);
94668 discard:
94669 kfree_skb(skb);
94670 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94671 TCP_SKB_CB(skb)->sacked = 0;
94672
94673 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94674 - if (!sk)
94675 + if (!sk) {
94676 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94677 + ret = 1;
94678 +#endif
94679 goto no_tcp_socket;
94680 -
94681 + }
94682 process:
94683 - if (sk->sk_state == TCP_TIME_WAIT)
94684 + if (sk->sk_state == TCP_TIME_WAIT) {
94685 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94686 + ret = 2;
94687 +#endif
94688 goto do_time_wait;
94689 + }
94690
94691 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94692 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94693 @@ -2058,6 +2072,10 @@ csum_error:
94694 bad_packet:
94695 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94696 } else {
94697 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94698 + if (!grsec_enable_blackhole || (ret == 1 &&
94699 + (skb->dev->flags & IFF_LOOPBACK)))
94700 +#endif
94701 tcp_v4_send_reset(NULL, skb);
94702 }
94703
94704 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94705 index 0f01788..d52a859 100644
94706 --- a/net/ipv4/tcp_minisocks.c
94707 +++ b/net/ipv4/tcp_minisocks.c
94708 @@ -27,6 +27,10 @@
94709 #include <net/inet_common.h>
94710 #include <net/xfrm.h>
94711
94712 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94713 +extern int grsec_enable_blackhole;
94714 +#endif
94715 +
94716 int sysctl_tcp_syncookies __read_mostly = 1;
94717 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94718
94719 @@ -717,7 +721,10 @@ embryonic_reset:
94720 * avoid becoming vulnerable to outside attack aiming at
94721 * resetting legit local connections.
94722 */
94723 - req->rsk_ops->send_reset(sk, skb);
94724 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94725 + if (!grsec_enable_blackhole)
94726 +#endif
94727 + req->rsk_ops->send_reset(sk, skb);
94728 } else if (fastopen) { /* received a valid RST pkt */
94729 reqsk_fastopen_remove(sk, req, true);
94730 tcp_reset(sk);
94731 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94732 index d4943f6..e7a74a5 100644
94733 --- a/net/ipv4/tcp_probe.c
94734 +++ b/net/ipv4/tcp_probe.c
94735 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94736 if (cnt + width >= len)
94737 break;
94738
94739 - if (copy_to_user(buf + cnt, tbuf, width))
94740 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94741 return -EFAULT;
94742 cnt += width;
94743 }
94744 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94745 index 4b85e6f..22f9ac9 100644
94746 --- a/net/ipv4/tcp_timer.c
94747 +++ b/net/ipv4/tcp_timer.c
94748 @@ -22,6 +22,10 @@
94749 #include <linux/gfp.h>
94750 #include <net/tcp.h>
94751
94752 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94753 +extern int grsec_lastack_retries;
94754 +#endif
94755 +
94756 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94757 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94758 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94759 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94760 }
94761 }
94762
94763 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94764 + if ((sk->sk_state == TCP_LAST_ACK) &&
94765 + (grsec_lastack_retries > 0) &&
94766 + (grsec_lastack_retries < retry_until))
94767 + retry_until = grsec_lastack_retries;
94768 +#endif
94769 +
94770 if (retransmits_timed_out(sk, retry_until,
94771 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94772 /* Has it gone just too far? */
94773 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94774 index 93b731d..5a2dd92 100644
94775 --- a/net/ipv4/udp.c
94776 +++ b/net/ipv4/udp.c
94777 @@ -87,6 +87,7 @@
94778 #include <linux/types.h>
94779 #include <linux/fcntl.h>
94780 #include <linux/module.h>
94781 +#include <linux/security.h>
94782 #include <linux/socket.h>
94783 #include <linux/sockios.h>
94784 #include <linux/igmp.h>
94785 @@ -111,6 +112,10 @@
94786 #include <trace/events/skb.h>
94787 #include "udp_impl.h"
94788
94789 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94790 +extern int grsec_enable_blackhole;
94791 +#endif
94792 +
94793 struct udp_table udp_table __read_mostly;
94794 EXPORT_SYMBOL(udp_table);
94795
94796 @@ -594,6 +599,9 @@ found:
94797 return s;
94798 }
94799
94800 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94801 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94802 +
94803 /*
94804 * This routine is called by the ICMP module when it gets some
94805 * sort of error condition. If err < 0 then the socket should
94806 @@ -890,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94807 dport = usin->sin_port;
94808 if (dport == 0)
94809 return -EINVAL;
94810 +
94811 + err = gr_search_udp_sendmsg(sk, usin);
94812 + if (err)
94813 + return err;
94814 } else {
94815 if (sk->sk_state != TCP_ESTABLISHED)
94816 return -EDESTADDRREQ;
94817 +
94818 + err = gr_search_udp_sendmsg(sk, NULL);
94819 + if (err)
94820 + return err;
94821 +
94822 daddr = inet->inet_daddr;
94823 dport = inet->inet_dport;
94824 /* Open fast path for connected socket.
94825 @@ -1136,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
94826 IS_UDPLITE(sk));
94827 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94828 IS_UDPLITE(sk));
94829 - atomic_inc(&sk->sk_drops);
94830 + atomic_inc_unchecked(&sk->sk_drops);
94831 __skb_unlink(skb, rcvq);
94832 __skb_queue_tail(&list_kill, skb);
94833 }
94834 @@ -1222,6 +1239,10 @@ try_again:
94835 if (!skb)
94836 goto out;
94837
94838 + err = gr_search_udp_recvmsg(sk, skb);
94839 + if (err)
94840 + goto out_free;
94841 +
94842 ulen = skb->len - sizeof(struct udphdr);
94843 copied = len;
94844 if (copied > ulen)
94845 @@ -1255,7 +1276,7 @@ try_again:
94846 if (unlikely(err)) {
94847 trace_kfree_skb(skb, udp_recvmsg);
94848 if (!peeked) {
94849 - atomic_inc(&sk->sk_drops);
94850 + atomic_inc_unchecked(&sk->sk_drops);
94851 UDP_INC_STATS_USER(sock_net(sk),
94852 UDP_MIB_INERRORS, is_udplite);
94853 }
94854 @@ -1542,7 +1563,7 @@ csum_error:
94855 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94856 drop:
94857 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94858 - atomic_inc(&sk->sk_drops);
94859 + atomic_inc_unchecked(&sk->sk_drops);
94860 kfree_skb(skb);
94861 return -1;
94862 }
94863 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94864 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94865
94866 if (!skb1) {
94867 - atomic_inc(&sk->sk_drops);
94868 + atomic_inc_unchecked(&sk->sk_drops);
94869 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94870 IS_UDPLITE(sk));
94871 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94872 @@ -1730,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94873 goto csum_error;
94874
94875 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94876 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94877 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94878 +#endif
94879 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
94880
94881 /*
94882 @@ -2160,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
94883 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94884 0, sock_i_ino(sp),
94885 atomic_read(&sp->sk_refcnt), sp,
94886 - atomic_read(&sp->sk_drops), len);
94887 + atomic_read_unchecked(&sp->sk_drops), len);
94888 }
94889
94890 int udp4_seq_show(struct seq_file *seq, void *v)
94891 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
94892 index 9a459be..086b866 100644
94893 --- a/net/ipv4/xfrm4_policy.c
94894 +++ b/net/ipv4/xfrm4_policy.c
94895 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
94896
94897 static int __net_init xfrm4_net_init(struct net *net)
94898 {
94899 - struct ctl_table *table;
94900 + ctl_table_no_const *table = NULL;
94901 struct ctl_table_header *hdr;
94902
94903 - table = xfrm4_policy_table;
94904 if (!net_eq(net, &init_net)) {
94905 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94906 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94907 if (!table)
94908 goto err_alloc;
94909
94910 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
94911 - }
94912 -
94913 - hdr = register_net_sysctl(net, "net/ipv4", table);
94914 + hdr = register_net_sysctl(net, "net/ipv4", table);
94915 + } else
94916 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
94917 if (!hdr)
94918 goto err_reg;
94919
94920 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
94921 return 0;
94922
94923 err_reg:
94924 - if (!net_eq(net, &init_net))
94925 - kfree(table);
94926 + kfree(table);
94927 err_alloc:
94928 return -ENOMEM;
94929 }
94930 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
94931 index fb8c94c..80a31d8 100644
94932 --- a/net/ipv6/addrconf.c
94933 +++ b/net/ipv6/addrconf.c
94934 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
94935 idx = 0;
94936 head = &net->dev_index_head[h];
94937 rcu_read_lock();
94938 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
94939 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
94940 net->dev_base_seq;
94941 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94942 if (idx < s_idx)
94943 @@ -1124,12 +1124,10 @@ retry:
94944 if (ifp->flags & IFA_F_OPTIMISTIC)
94945 addr_flags |= IFA_F_OPTIMISTIC;
94946
94947 - ift = !max_addresses ||
94948 - ipv6_count_addresses(idev) < max_addresses ?
94949 - ipv6_add_addr(idev, &addr, tmp_plen,
94950 - ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
94951 - addr_flags) : NULL;
94952 - if (IS_ERR_OR_NULL(ift)) {
94953 + ift = ipv6_add_addr(idev, &addr, tmp_plen,
94954 + ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
94955 + addr_flags);
94956 + if (IS_ERR(ift)) {
94957 in6_ifa_put(ifp);
94958 in6_dev_put(idev);
94959 pr_info("%s: retry temporary address regeneration\n", __func__);
94960 @@ -2380,7 +2378,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
94961 p.iph.ihl = 5;
94962 p.iph.protocol = IPPROTO_IPV6;
94963 p.iph.ttl = 64;
94964 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
94965 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
94966
94967 if (ops->ndo_do_ioctl) {
94968 mm_segment_t oldfs = get_fs();
94969 @@ -4002,7 +4000,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
94970 s_ip_idx = ip_idx = cb->args[2];
94971
94972 rcu_read_lock();
94973 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94974 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94975 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
94976 idx = 0;
94977 head = &net->dev_index_head[h];
94978 @@ -4587,7 +4585,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94979 dst_free(&ifp->rt->dst);
94980 break;
94981 }
94982 - atomic_inc(&net->ipv6.dev_addr_genid);
94983 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
94984 }
94985
94986 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94987 @@ -4607,7 +4605,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
94988 int *valp = ctl->data;
94989 int val = *valp;
94990 loff_t pos = *ppos;
94991 - ctl_table lctl;
94992 + ctl_table_no_const lctl;
94993 int ret;
94994
94995 /*
94996 @@ -4689,7 +4687,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
94997 int *valp = ctl->data;
94998 int val = *valp;
94999 loff_t pos = *ppos;
95000 - ctl_table lctl;
95001 + ctl_table_no_const lctl;
95002 int ret;
95003
95004 /*
95005 diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
95006 index 40ffd72..aeac0dc 100644
95007 --- a/net/ipv6/esp6.c
95008 +++ b/net/ipv6/esp6.c
95009 @@ -425,7 +425,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
95010 net_adj = 0;
95011
95012 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
95013 - net_adj) & ~(align - 1)) + (net_adj - 2);
95014 + net_adj) & ~(align - 1)) + net_adj - 2;
95015 }
95016
95017 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
95018 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
95019 index b4ff0a4..db9b764 100644
95020 --- a/net/ipv6/icmp.c
95021 +++ b/net/ipv6/icmp.c
95022 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
95023
95024 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
95025 {
95026 - struct ctl_table *table;
95027 + ctl_table_no_const *table;
95028
95029 table = kmemdup(ipv6_icmp_table_template,
95030 sizeof(ipv6_icmp_table_template),
95031 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
95032 index ecd6073..58162ae 100644
95033 --- a/net/ipv6/ip6_gre.c
95034 +++ b/net/ipv6/ip6_gre.c
95035 @@ -74,7 +74,7 @@ struct ip6gre_net {
95036 struct net_device *fb_tunnel_dev;
95037 };
95038
95039 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
95040 +static struct rtnl_link_ops ip6gre_link_ops;
95041 static int ip6gre_tunnel_init(struct net_device *dev);
95042 static void ip6gre_tunnel_setup(struct net_device *dev);
95043 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
95044 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
95045 }
95046
95047
95048 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
95049 +static struct inet6_protocol ip6gre_protocol = {
95050 .handler = ip6gre_rcv,
95051 .err_handler = ip6gre_err,
95052 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
95053 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
95054 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
95055 };
95056
95057 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95058 +static struct rtnl_link_ops ip6gre_link_ops = {
95059 .kind = "ip6gre",
95060 .maxtype = IFLA_GRE_MAX,
95061 .policy = ip6gre_policy,
95062 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95063 .fill_info = ip6gre_fill_info,
95064 };
95065
95066 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
95067 +static struct rtnl_link_ops ip6gre_tap_ops = {
95068 .kind = "ip6gretap",
95069 .maxtype = IFLA_GRE_MAX,
95070 .policy = ip6gre_policy,
95071 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
95072 index 1e55866..b398dab 100644
95073 --- a/net/ipv6/ip6_tunnel.c
95074 +++ b/net/ipv6/ip6_tunnel.c
95075 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
95076
95077 static int ip6_tnl_dev_init(struct net_device *dev);
95078 static void ip6_tnl_dev_setup(struct net_device *dev);
95079 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
95080 +static struct rtnl_link_ops ip6_link_ops;
95081
95082 static int ip6_tnl_net_id __read_mostly;
95083 struct ip6_tnl_net {
95084 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
95085 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
95086 };
95087
95088 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
95089 +static struct rtnl_link_ops ip6_link_ops = {
95090 .kind = "ip6tnl",
95091 .maxtype = IFLA_IPTUN_MAX,
95092 .policy = ip6_tnl_policy,
95093 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
95094 index d1e2e8e..51c19ae 100644
95095 --- a/net/ipv6/ipv6_sockglue.c
95096 +++ b/net/ipv6/ipv6_sockglue.c
95097 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
95098 if (sk->sk_type != SOCK_STREAM)
95099 return -ENOPROTOOPT;
95100
95101 - msg.msg_control = optval;
95102 + msg.msg_control = (void __force_kernel *)optval;
95103 msg.msg_controllen = len;
95104 msg.msg_flags = flags;
95105
95106 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
95107 index 44400c2..8e11f52 100644
95108 --- a/net/ipv6/netfilter/ip6_tables.c
95109 +++ b/net/ipv6/netfilter/ip6_tables.c
95110 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
95111 #endif
95112
95113 static int get_info(struct net *net, void __user *user,
95114 - const int *len, int compat)
95115 + int len, int compat)
95116 {
95117 char name[XT_TABLE_MAXNAMELEN];
95118 struct xt_table *t;
95119 int ret;
95120
95121 - if (*len != sizeof(struct ip6t_getinfo)) {
95122 - duprintf("length %u != %zu\n", *len,
95123 + if (len != sizeof(struct ip6t_getinfo)) {
95124 + duprintf("length %u != %zu\n", len,
95125 sizeof(struct ip6t_getinfo));
95126 return -EINVAL;
95127 }
95128 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
95129 info.size = private->size;
95130 strcpy(info.name, name);
95131
95132 - if (copy_to_user(user, &info, *len) != 0)
95133 + if (copy_to_user(user, &info, len) != 0)
95134 ret = -EFAULT;
95135 else
95136 ret = 0;
95137 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95138
95139 switch (cmd) {
95140 case IP6T_SO_GET_INFO:
95141 - ret = get_info(sock_net(sk), user, len, 1);
95142 + ret = get_info(sock_net(sk), user, *len, 1);
95143 break;
95144 case IP6T_SO_GET_ENTRIES:
95145 ret = compat_get_entries(sock_net(sk), user, len);
95146 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95147
95148 switch (cmd) {
95149 case IP6T_SO_GET_INFO:
95150 - ret = get_info(sock_net(sk), user, len, 0);
95151 + ret = get_info(sock_net(sk), user, *len, 0);
95152 break;
95153
95154 case IP6T_SO_GET_ENTRIES:
95155 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
95156 index dffdc1a..ccc6678 100644
95157 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
95158 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
95159 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
95160
95161 static int nf_ct_frag6_sysctl_register(struct net *net)
95162 {
95163 - struct ctl_table *table;
95164 + ctl_table_no_const *table = NULL;
95165 struct ctl_table_header *hdr;
95166
95167 - table = nf_ct_frag6_sysctl_table;
95168 if (!net_eq(net, &init_net)) {
95169 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
95170 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
95171 GFP_KERNEL);
95172 if (table == NULL)
95173 goto err_alloc;
95174 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95175 table[0].data = &net->nf_frag.frags.timeout;
95176 table[1].data = &net->nf_frag.frags.low_thresh;
95177 table[2].data = &net->nf_frag.frags.high_thresh;
95178 - }
95179 -
95180 - hdr = register_net_sysctl(net, "net/netfilter", table);
95181 + hdr = register_net_sysctl(net, "net/netfilter", table);
95182 + } else
95183 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
95184 if (hdr == NULL)
95185 goto err_reg;
95186
95187 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95188 return 0;
95189
95190 err_reg:
95191 - if (!net_eq(net, &init_net))
95192 - kfree(table);
95193 + kfree(table);
95194 err_alloc:
95195 return -ENOMEM;
95196 }
95197 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
95198 index c2e73e6..12cca6f 100644
95199 --- a/net/ipv6/output_core.c
95200 +++ b/net/ipv6/output_core.c
95201 @@ -8,8 +8,8 @@
95202
95203 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95204 {
95205 - static atomic_t ipv6_fragmentation_id;
95206 - int old, new;
95207 + static atomic_unchecked_t ipv6_fragmentation_id;
95208 + int id;
95209
95210 #if IS_ENABLED(CONFIG_IPV6)
95211 if (rt && !(rt->dst.flags & DST_NOPEER)) {
95212 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95213 }
95214 }
95215 #endif
95216 - do {
95217 - old = atomic_read(&ipv6_fragmentation_id);
95218 - new = old + 1;
95219 - if (!new)
95220 - new = 1;
95221 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
95222 - fhdr->identification = htonl(new);
95223 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95224 + if (!id)
95225 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95226 + fhdr->identification = htonl(id);
95227 }
95228 EXPORT_SYMBOL(ipv6_select_ident);
95229
95230 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
95231 index eedff8c..7d7e24a 100644
95232 --- a/net/ipv6/raw.c
95233 +++ b/net/ipv6/raw.c
95234 @@ -108,7 +108,7 @@ found:
95235 */
95236 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
95237 {
95238 - struct icmp6hdr *_hdr;
95239 + struct icmp6hdr _hdr;
95240 const struct icmp6hdr *hdr;
95241
95242 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
95243 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
95244 {
95245 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
95246 skb_checksum_complete(skb)) {
95247 - atomic_inc(&sk->sk_drops);
95248 + atomic_inc_unchecked(&sk->sk_drops);
95249 kfree_skb(skb);
95250 return NET_RX_DROP;
95251 }
95252 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95253 struct raw6_sock *rp = raw6_sk(sk);
95254
95255 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
95256 - atomic_inc(&sk->sk_drops);
95257 + atomic_inc_unchecked(&sk->sk_drops);
95258 kfree_skb(skb);
95259 return NET_RX_DROP;
95260 }
95261 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95262
95263 if (inet->hdrincl) {
95264 if (skb_checksum_complete(skb)) {
95265 - atomic_inc(&sk->sk_drops);
95266 + atomic_inc_unchecked(&sk->sk_drops);
95267 kfree_skb(skb);
95268 return NET_RX_DROP;
95269 }
95270 @@ -602,7 +602,7 @@ out:
95271 return err;
95272 }
95273
95274 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
95275 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
95276 struct flowi6 *fl6, struct dst_entry **dstp,
95277 unsigned int flags)
95278 {
95279 @@ -914,12 +914,15 @@ do_confirm:
95280 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
95281 char __user *optval, int optlen)
95282 {
95283 + struct icmp6_filter filter;
95284 +
95285 switch (optname) {
95286 case ICMPV6_FILTER:
95287 if (optlen > sizeof(struct icmp6_filter))
95288 optlen = sizeof(struct icmp6_filter);
95289 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
95290 + if (copy_from_user(&filter, optval, optlen))
95291 return -EFAULT;
95292 + raw6_sk(sk)->filter = filter;
95293 return 0;
95294 default:
95295 return -ENOPROTOOPT;
95296 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95297 char __user *optval, int __user *optlen)
95298 {
95299 int len;
95300 + struct icmp6_filter filter;
95301
95302 switch (optname) {
95303 case ICMPV6_FILTER:
95304 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95305 len = sizeof(struct icmp6_filter);
95306 if (put_user(len, optlen))
95307 return -EFAULT;
95308 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
95309 + filter = raw6_sk(sk)->filter;
95310 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
95311 return -EFAULT;
95312 return 0;
95313 default:
95314 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
95315 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
95316 0,
95317 sock_i_ino(sp),
95318 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
95319 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
95320 }
95321
95322 static int raw6_seq_show(struct seq_file *seq, void *v)
95323 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
95324 index 790d9f4..68ae078 100644
95325 --- a/net/ipv6/reassembly.c
95326 +++ b/net/ipv6/reassembly.c
95327 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
95328
95329 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95330 {
95331 - struct ctl_table *table;
95332 + ctl_table_no_const *table = NULL;
95333 struct ctl_table_header *hdr;
95334
95335 - table = ip6_frags_ns_ctl_table;
95336 if (!net_eq(net, &init_net)) {
95337 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95338 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95339 if (table == NULL)
95340 goto err_alloc;
95341
95342 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95343 /* Don't export sysctls to unprivileged users */
95344 if (net->user_ns != &init_user_ns)
95345 table[0].procname = NULL;
95346 - }
95347 + hdr = register_net_sysctl(net, "net/ipv6", table);
95348 + } else
95349 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
95350
95351 - hdr = register_net_sysctl(net, "net/ipv6", table);
95352 if (hdr == NULL)
95353 goto err_reg;
95354
95355 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95356 return 0;
95357
95358 err_reg:
95359 - if (!net_eq(net, &init_net))
95360 - kfree(table);
95361 + kfree(table);
95362 err_alloc:
95363 return -ENOMEM;
95364 }
95365 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
95366 index bacce6c..9d1741a 100644
95367 --- a/net/ipv6/route.c
95368 +++ b/net/ipv6/route.c
95369 @@ -2903,7 +2903,7 @@ ctl_table ipv6_route_table_template[] = {
95370
95371 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
95372 {
95373 - struct ctl_table *table;
95374 + ctl_table_no_const *table;
95375
95376 table = kmemdup(ipv6_route_table_template,
95377 sizeof(ipv6_route_table_template),
95378 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
95379 index 60df36d..f3ab7c8 100644
95380 --- a/net/ipv6/sit.c
95381 +++ b/net/ipv6/sit.c
95382 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
95383 static void ipip6_dev_free(struct net_device *dev);
95384 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
95385 __be32 *v4dst);
95386 -static struct rtnl_link_ops sit_link_ops __read_mostly;
95387 +static struct rtnl_link_ops sit_link_ops;
95388
95389 static int sit_net_id __read_mostly;
95390 struct sit_net {
95391 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
95392 #endif
95393 };
95394
95395 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
95396 +static struct rtnl_link_ops sit_link_ops = {
95397 .kind = "sit",
95398 .maxtype = IFLA_IPTUN_MAX,
95399 .policy = ipip6_policy,
95400 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
95401 index e85c48b..b8268d3 100644
95402 --- a/net/ipv6/sysctl_net_ipv6.c
95403 +++ b/net/ipv6/sysctl_net_ipv6.c
95404 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
95405
95406 static int __net_init ipv6_sysctl_net_init(struct net *net)
95407 {
95408 - struct ctl_table *ipv6_table;
95409 + ctl_table_no_const *ipv6_table;
95410 struct ctl_table *ipv6_route_table;
95411 struct ctl_table *ipv6_icmp_table;
95412 int err;
95413 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
95414 index 0a17ed9..5600868 100644
95415 --- a/net/ipv6/tcp_ipv6.c
95416 +++ b/net/ipv6/tcp_ipv6.c
95417 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
95418 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
95419 }
95420
95421 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95422 +extern int grsec_enable_blackhole;
95423 +#endif
95424 +
95425 static void tcp_v6_hash(struct sock *sk)
95426 {
95427 if (sk->sk_state != TCP_CLOSE) {
95428 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
95429 return 0;
95430
95431 reset:
95432 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95433 + if (!grsec_enable_blackhole)
95434 +#endif
95435 tcp_v6_send_reset(sk, skb);
95436 discard:
95437 if (opt_skb)
95438 @@ -1426,7 +1433,7 @@ ipv6_pktoptions:
95439 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
95440 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
95441 if (np->rxopt.bits.rxtclass)
95442 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
95443 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
95444 if (ipv6_opt_accepted(sk, opt_skb)) {
95445 skb_set_owner_r(opt_skb, sk);
95446 opt_skb = xchg(&np->pktoptions, opt_skb);
95447 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
95448 TCP_SKB_CB(skb)->sacked = 0;
95449
95450 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95451 - if (!sk)
95452 + if (!sk) {
95453 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95454 + ret = 1;
95455 +#endif
95456 goto no_tcp_socket;
95457 + }
95458
95459 process:
95460 - if (sk->sk_state == TCP_TIME_WAIT)
95461 + if (sk->sk_state == TCP_TIME_WAIT) {
95462 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95463 + ret = 2;
95464 +#endif
95465 goto do_time_wait;
95466 + }
95467
95468 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
95469 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95470 @@ -1536,6 +1551,10 @@ csum_error:
95471 bad_packet:
95472 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95473 } else {
95474 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95475 + if (!grsec_enable_blackhole || (ret == 1 &&
95476 + (skb->dev->flags & IFF_LOOPBACK)))
95477 +#endif
95478 tcp_v6_send_reset(NULL, skb);
95479 }
95480
95481 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
95482 index e7b28f9..d09c290 100644
95483 --- a/net/ipv6/udp.c
95484 +++ b/net/ipv6/udp.c
95485 @@ -52,6 +52,10 @@
95486 #include <trace/events/skb.h>
95487 #include "udp_impl.h"
95488
95489 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95490 +extern int grsec_enable_blackhole;
95491 +#endif
95492 +
95493 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
95494 {
95495 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
95496 @@ -419,7 +423,7 @@ try_again:
95497 if (unlikely(err)) {
95498 trace_kfree_skb(skb, udpv6_recvmsg);
95499 if (!peeked) {
95500 - atomic_inc(&sk->sk_drops);
95501 + atomic_inc_unchecked(&sk->sk_drops);
95502 if (is_udp4)
95503 UDP_INC_STATS_USER(sock_net(sk),
95504 UDP_MIB_INERRORS,
95505 @@ -665,7 +669,7 @@ csum_error:
95506 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
95507 drop:
95508 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
95509 - atomic_inc(&sk->sk_drops);
95510 + atomic_inc_unchecked(&sk->sk_drops);
95511 kfree_skb(skb);
95512 return -1;
95513 }
95514 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
95515 if (likely(skb1 == NULL))
95516 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
95517 if (!skb1) {
95518 - atomic_inc(&sk->sk_drops);
95519 + atomic_inc_unchecked(&sk->sk_drops);
95520 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
95521 IS_UDPLITE(sk));
95522 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95523 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95524 goto csum_error;
95525
95526 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95527 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95528 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95529 +#endif
95530 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
95531
95532 kfree_skb(skb);
95533 @@ -1392,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
95534 0,
95535 sock_i_ino(sp),
95536 atomic_read(&sp->sk_refcnt), sp,
95537 - atomic_read(&sp->sk_drops));
95538 + atomic_read_unchecked(&sp->sk_drops));
95539 }
95540
95541 int udp6_seq_show(struct seq_file *seq, void *v)
95542 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
95543 index 23ed03d..465a71d 100644
95544 --- a/net/ipv6/xfrm6_policy.c
95545 +++ b/net/ipv6/xfrm6_policy.c
95546 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
95547
95548 static int __net_init xfrm6_net_init(struct net *net)
95549 {
95550 - struct ctl_table *table;
95551 + ctl_table_no_const *table = NULL;
95552 struct ctl_table_header *hdr;
95553
95554 - table = xfrm6_policy_table;
95555 if (!net_eq(net, &init_net)) {
95556 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95557 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95558 if (!table)
95559 goto err_alloc;
95560
95561 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
95562 - }
95563 + hdr = register_net_sysctl(net, "net/ipv6", table);
95564 + } else
95565 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
95566
95567 - hdr = register_net_sysctl(net, "net/ipv6", table);
95568 if (!hdr)
95569 goto err_reg;
95570
95571 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
95572 return 0;
95573
95574 err_reg:
95575 - if (!net_eq(net, &init_net))
95576 - kfree(table);
95577 + kfree(table);
95578 err_alloc:
95579 return -ENOMEM;
95580 }
95581 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
95582 index 41ac7938..75e3bb1 100644
95583 --- a/net/irda/ircomm/ircomm_tty.c
95584 +++ b/net/irda/ircomm/ircomm_tty.c
95585 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95586 add_wait_queue(&port->open_wait, &wait);
95587
95588 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
95589 - __FILE__, __LINE__, tty->driver->name, port->count);
95590 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95591
95592 spin_lock_irqsave(&port->lock, flags);
95593 if (!tty_hung_up_p(filp))
95594 - port->count--;
95595 + atomic_dec(&port->count);
95596 port->blocked_open++;
95597 spin_unlock_irqrestore(&port->lock, flags);
95598
95599 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95600 }
95601
95602 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95603 - __FILE__, __LINE__, tty->driver->name, port->count);
95604 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95605
95606 schedule();
95607 }
95608 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95609
95610 spin_lock_irqsave(&port->lock, flags);
95611 if (!tty_hung_up_p(filp))
95612 - port->count++;
95613 + atomic_inc(&port->count);
95614 port->blocked_open--;
95615 spin_unlock_irqrestore(&port->lock, flags);
95616
95617 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95618 - __FILE__, __LINE__, tty->driver->name, port->count);
95619 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95620
95621 if (!retval)
95622 port->flags |= ASYNC_NORMAL_ACTIVE;
95623 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95624
95625 /* ++ is not atomic, so this should be protected - Jean II */
95626 spin_lock_irqsave(&self->port.lock, flags);
95627 - self->port.count++;
95628 + atomic_inc(&self->port.count);
95629 spin_unlock_irqrestore(&self->port.lock, flags);
95630 tty_port_tty_set(&self->port, tty);
95631
95632 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95633 - self->line, self->port.count);
95634 + self->line, atomic_read(&self->port.count));
95635
95636 /* Not really used by us, but lets do it anyway */
95637 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95638 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95639 tty_kref_put(port->tty);
95640 }
95641 port->tty = NULL;
95642 - port->count = 0;
95643 + atomic_set(&port->count, 0);
95644 spin_unlock_irqrestore(&port->lock, flags);
95645
95646 wake_up_interruptible(&port->open_wait);
95647 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95648 seq_putc(m, '\n');
95649
95650 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95651 - seq_printf(m, "Open count: %d\n", self->port.count);
95652 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95653 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95654 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95655
95656 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95657 index ae69165..c8b82d8 100644
95658 --- a/net/iucv/af_iucv.c
95659 +++ b/net/iucv/af_iucv.c
95660 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95661
95662 write_lock_bh(&iucv_sk_list.lock);
95663
95664 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95665 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95666 while (__iucv_get_sock_by_name(name)) {
95667 sprintf(name, "%08x",
95668 - atomic_inc_return(&iucv_sk_list.autobind_name));
95669 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95670 }
95671
95672 write_unlock_bh(&iucv_sk_list.lock);
95673 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95674 index 4fe76ff..426a904 100644
95675 --- a/net/iucv/iucv.c
95676 +++ b/net/iucv/iucv.c
95677 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
95678 return NOTIFY_OK;
95679 }
95680
95681 -static struct notifier_block __refdata iucv_cpu_notifier = {
95682 +static struct notifier_block iucv_cpu_notifier = {
95683 .notifier_call = iucv_cpu_notify,
95684 };
95685
95686 diff --git a/net/key/af_key.c b/net/key/af_key.c
95687 index ab8bd2c..cd2d641 100644
95688 --- a/net/key/af_key.c
95689 +++ b/net/key/af_key.c
95690 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95691 static u32 get_acqseq(void)
95692 {
95693 u32 res;
95694 - static atomic_t acqseq;
95695 + static atomic_unchecked_t acqseq;
95696
95697 do {
95698 - res = atomic_inc_return(&acqseq);
95699 + res = atomic_inc_return_unchecked(&acqseq);
95700 } while (!res);
95701 return res;
95702 }
95703 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95704 index ae36f8e..09d42ac 100644
95705 --- a/net/mac80211/cfg.c
95706 +++ b/net/mac80211/cfg.c
95707 @@ -806,7 +806,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95708 ret = ieee80211_vif_use_channel(sdata, chandef,
95709 IEEE80211_CHANCTX_EXCLUSIVE);
95710 }
95711 - } else if (local->open_count == local->monitors) {
95712 + } else if (local_read(&local->open_count) == local->monitors) {
95713 local->_oper_chandef = *chandef;
95714 ieee80211_hw_config(local, 0);
95715 }
95716 @@ -2922,7 +2922,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95717 else
95718 local->probe_req_reg--;
95719
95720 - if (!local->open_count)
95721 + if (!local_read(&local->open_count))
95722 break;
95723
95724 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95725 @@ -3385,8 +3385,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95726 if (chanctx_conf) {
95727 *chandef = chanctx_conf->def;
95728 ret = 0;
95729 - } else if (local->open_count > 0 &&
95730 - local->open_count == local->monitors &&
95731 + } else if (local_read(&local->open_count) > 0 &&
95732 + local_read(&local->open_count) == local->monitors &&
95733 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95734 if (local->use_chanctx)
95735 *chandef = local->monitor_chandef;
95736 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95737 index 9ca8e32..48e4a9b 100644
95738 --- a/net/mac80211/ieee80211_i.h
95739 +++ b/net/mac80211/ieee80211_i.h
95740 @@ -28,6 +28,7 @@
95741 #include <net/ieee80211_radiotap.h>
95742 #include <net/cfg80211.h>
95743 #include <net/mac80211.h>
95744 +#include <asm/local.h>
95745 #include "key.h"
95746 #include "sta_info.h"
95747 #include "debug.h"
95748 @@ -891,7 +892,7 @@ struct ieee80211_local {
95749 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95750 spinlock_t queue_stop_reason_lock;
95751
95752 - int open_count;
95753 + local_t open_count;
95754 int monitors, cooked_mntrs;
95755 /* number of interfaces with corresponding FIF_ flags */
95756 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95757 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95758 index 514e90f..56f22bf 100644
95759 --- a/net/mac80211/iface.c
95760 +++ b/net/mac80211/iface.c
95761 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95762 break;
95763 }
95764
95765 - if (local->open_count == 0) {
95766 + if (local_read(&local->open_count) == 0) {
95767 res = drv_start(local);
95768 if (res)
95769 goto err_del_bss;
95770 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95771 break;
95772 }
95773
95774 - if (local->monitors == 0 && local->open_count == 0) {
95775 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95776 res = ieee80211_add_virtual_monitor(local);
95777 if (res)
95778 goto err_stop;
95779 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95780 atomic_inc(&local->iff_promiscs);
95781
95782 if (coming_up)
95783 - local->open_count++;
95784 + local_inc(&local->open_count);
95785
95786 if (hw_reconf_flags)
95787 ieee80211_hw_config(local, hw_reconf_flags);
95788 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95789 err_del_interface:
95790 drv_remove_interface(local, sdata);
95791 err_stop:
95792 - if (!local->open_count)
95793 + if (!local_read(&local->open_count))
95794 drv_stop(local);
95795 err_del_bss:
95796 sdata->bss = NULL;
95797 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95798 }
95799
95800 if (going_down)
95801 - local->open_count--;
95802 + local_dec(&local->open_count);
95803
95804 switch (sdata->vif.type) {
95805 case NL80211_IFTYPE_AP_VLAN:
95806 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95807 }
95808 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95809
95810 - if (local->open_count == 0)
95811 + if (local_read(&local->open_count) == 0)
95812 ieee80211_clear_tx_pending(local);
95813
95814 /*
95815 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95816
95817 ieee80211_recalc_ps(local, -1);
95818
95819 - if (local->open_count == 0) {
95820 + if (local_read(&local->open_count) == 0) {
95821 ieee80211_stop_device(local);
95822
95823 /* no reconfiguring after stop! */
95824 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95825 ieee80211_configure_filter(local);
95826 ieee80211_hw_config(local, hw_reconf_flags);
95827
95828 - if (local->monitors == local->open_count)
95829 + if (local->monitors == local_read(&local->open_count))
95830 ieee80211_add_virtual_monitor(local);
95831 }
95832
95833 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
95834 index 8a7bfc4..be07e86 100644
95835 --- a/net/mac80211/main.c
95836 +++ b/net/mac80211/main.c
95837 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
95838 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
95839 IEEE80211_CONF_CHANGE_POWER);
95840
95841 - if (changed && local->open_count) {
95842 + if (changed && local_read(&local->open_count)) {
95843 ret = drv_config(local, changed);
95844 /*
95845 * Goal:
95846 @@ -921,7 +921,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
95847 hw->queues = IEEE80211_MAX_QUEUES;
95848
95849 local->workqueue =
95850 - alloc_ordered_workqueue(wiphy_name(local->hw.wiphy), 0);
95851 + alloc_ordered_workqueue("%s", 0, wiphy_name(local->hw.wiphy));
95852 if (!local->workqueue) {
95853 result = -ENOMEM;
95854 goto fail_workqueue;
95855 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
95856 index 3401262..d5cd68d 100644
95857 --- a/net/mac80211/pm.c
95858 +++ b/net/mac80211/pm.c
95859 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95860 struct ieee80211_sub_if_data *sdata;
95861 struct sta_info *sta;
95862
95863 - if (!local->open_count)
95864 + if (!local_read(&local->open_count))
95865 goto suspend;
95866
95867 ieee80211_scan_cancel(local);
95868 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95869 cancel_work_sync(&local->dynamic_ps_enable_work);
95870 del_timer_sync(&local->dynamic_ps_timer);
95871
95872 - local->wowlan = wowlan && local->open_count;
95873 + local->wowlan = wowlan && local_read(&local->open_count);
95874 if (local->wowlan) {
95875 int err = drv_suspend(local, wowlan);
95876 if (err < 0) {
95877 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95878 WARN_ON(!list_empty(&local->chanctx_list));
95879
95880 /* stop hardware - this must stop RX */
95881 - if (local->open_count)
95882 + if (local_read(&local->open_count))
95883 ieee80211_stop_device(local);
95884
95885 suspend:
95886 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
95887 index a02bef3..f2f38dd 100644
95888 --- a/net/mac80211/rate.c
95889 +++ b/net/mac80211/rate.c
95890 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
95891
95892 ASSERT_RTNL();
95893
95894 - if (local->open_count)
95895 + if (local_read(&local->open_count))
95896 return -EBUSY;
95897
95898 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
95899 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
95900 index c97a065..ff61928 100644
95901 --- a/net/mac80211/rc80211_pid_debugfs.c
95902 +++ b/net/mac80211/rc80211_pid_debugfs.c
95903 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
95904
95905 spin_unlock_irqrestore(&events->lock, status);
95906
95907 - if (copy_to_user(buf, pb, p))
95908 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
95909 return -EFAULT;
95910
95911 return p;
95912 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
95913 index 72e6292..e6319eb 100644
95914 --- a/net/mac80211/util.c
95915 +++ b/net/mac80211/util.c
95916 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95917 }
95918 #endif
95919 /* everything else happens only if HW was up & running */
95920 - if (!local->open_count)
95921 + if (!local_read(&local->open_count))
95922 goto wake_up;
95923
95924 /*
95925 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95926 local->in_reconfig = false;
95927 barrier();
95928
95929 - if (local->monitors == local->open_count && local->monitors > 0)
95930 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
95931 ieee80211_add_virtual_monitor(local);
95932
95933 /*
95934 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
95935 index 56d22ca..87c778f 100644
95936 --- a/net/netfilter/Kconfig
95937 +++ b/net/netfilter/Kconfig
95938 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
95939
95940 To compile it as a module, choose M here. If unsure, say N.
95941
95942 +config NETFILTER_XT_MATCH_GRADM
95943 + tristate '"gradm" match support'
95944 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
95945 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
95946 + ---help---
95947 + The gradm match allows to match on grsecurity RBAC being enabled.
95948 + It is useful when iptables rules are applied early on bootup to
95949 + prevent connections to the machine (except from a trusted host)
95950 + while the RBAC system is disabled.
95951 +
95952 config NETFILTER_XT_MATCH_HASHLIMIT
95953 tristate '"hashlimit" match support'
95954 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
95955 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
95956 index a1abf87..dbcb7ee 100644
95957 --- a/net/netfilter/Makefile
95958 +++ b/net/netfilter/Makefile
95959 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
95960 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
95961 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
95962 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
95963 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
95964 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
95965 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
95966 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
95967 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
95968 index f771390..145b765 100644
95969 --- a/net/netfilter/ipset/ip_set_core.c
95970 +++ b/net/netfilter/ipset/ip_set_core.c
95971 @@ -1820,7 +1820,7 @@ done:
95972 return ret;
95973 }
95974
95975 -static struct nf_sockopt_ops so_set __read_mostly = {
95976 +static struct nf_sockopt_ops so_set = {
95977 .pf = PF_INET,
95978 .get_optmin = SO_IP_SET,
95979 .get_optmax = SO_IP_SET + 1,
95980 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
95981 index a083bda..da661c3 100644
95982 --- a/net/netfilter/ipvs/ip_vs_conn.c
95983 +++ b/net/netfilter/ipvs/ip_vs_conn.c
95984 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
95985 /* Increase the refcnt counter of the dest */
95986 ip_vs_dest_hold(dest);
95987
95988 - conn_flags = atomic_read(&dest->conn_flags);
95989 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
95990 if (cp->protocol != IPPROTO_UDP)
95991 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
95992 flags = cp->flags;
95993 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
95994
95995 cp->control = NULL;
95996 atomic_set(&cp->n_control, 0);
95997 - atomic_set(&cp->in_pkts, 0);
95998 + atomic_set_unchecked(&cp->in_pkts, 0);
95999
96000 cp->packet_xmit = NULL;
96001 cp->app = NULL;
96002 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
96003
96004 /* Don't drop the entry if its number of incoming packets is not
96005 located in [0, 8] */
96006 - i = atomic_read(&cp->in_pkts);
96007 + i = atomic_read_unchecked(&cp->in_pkts);
96008 if (i > 8 || i < 0) return 0;
96009
96010 if (!todrop_rate[i]) return 0;
96011 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
96012 index 23b8eb5..48a8959 100644
96013 --- a/net/netfilter/ipvs/ip_vs_core.c
96014 +++ b/net/netfilter/ipvs/ip_vs_core.c
96015 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
96016 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
96017 /* do not touch skb anymore */
96018
96019 - atomic_inc(&cp->in_pkts);
96020 + atomic_inc_unchecked(&cp->in_pkts);
96021 ip_vs_conn_put(cp);
96022 return ret;
96023 }
96024 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
96025 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
96026 pkts = sysctl_sync_threshold(ipvs);
96027 else
96028 - pkts = atomic_add_return(1, &cp->in_pkts);
96029 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96030
96031 if (ipvs->sync_state & IP_VS_STATE_MASTER)
96032 ip_vs_sync_conn(net, cp, pkts);
96033 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
96034 index 9e6c2a0..28552e2 100644
96035 --- a/net/netfilter/ipvs/ip_vs_ctl.c
96036 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
96037 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
96038 */
96039 ip_vs_rs_hash(ipvs, dest);
96040 }
96041 - atomic_set(&dest->conn_flags, conn_flags);
96042 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
96043
96044 /* bind the service */
96045 if (!dest->svc) {
96046 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
96047 * align with netns init in ip_vs_control_net_init()
96048 */
96049
96050 -static struct ctl_table vs_vars[] = {
96051 +static ctl_table_no_const vs_vars[] __read_only = {
96052 {
96053 .procname = "amemthresh",
96054 .maxlen = sizeof(int),
96055 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96056 " %-7s %-6d %-10d %-10d\n",
96057 &dest->addr.in6,
96058 ntohs(dest->port),
96059 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96060 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96061 atomic_read(&dest->weight),
96062 atomic_read(&dest->activeconns),
96063 atomic_read(&dest->inactconns));
96064 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96065 "%-7s %-6d %-10d %-10d\n",
96066 ntohl(dest->addr.ip),
96067 ntohs(dest->port),
96068 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96069 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96070 atomic_read(&dest->weight),
96071 atomic_read(&dest->activeconns),
96072 atomic_read(&dest->inactconns));
96073 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
96074
96075 entry.addr = dest->addr.ip;
96076 entry.port = dest->port;
96077 - entry.conn_flags = atomic_read(&dest->conn_flags);
96078 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
96079 entry.weight = atomic_read(&dest->weight);
96080 entry.u_threshold = dest->u_threshold;
96081 entry.l_threshold = dest->l_threshold;
96082 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
96083 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
96084 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
96085 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
96086 - (atomic_read(&dest->conn_flags) &
96087 + (atomic_read_unchecked(&dest->conn_flags) &
96088 IP_VS_CONN_F_FWD_MASK)) ||
96089 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
96090 atomic_read(&dest->weight)) ||
96091 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
96092 {
96093 int idx;
96094 struct netns_ipvs *ipvs = net_ipvs(net);
96095 - struct ctl_table *tbl;
96096 + ctl_table_no_const *tbl;
96097
96098 atomic_set(&ipvs->dropentry, 0);
96099 spin_lock_init(&ipvs->dropentry_lock);
96100 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
96101 index 5ea26bd..c9bc65f 100644
96102 --- a/net/netfilter/ipvs/ip_vs_lblc.c
96103 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
96104 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
96105 * IPVS LBLC sysctl table
96106 */
96107 #ifdef CONFIG_SYSCTL
96108 -static ctl_table vs_vars_table[] = {
96109 +static ctl_table_no_const vs_vars_table[] __read_only = {
96110 {
96111 .procname = "lblc_expiration",
96112 .data = NULL,
96113 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
96114 index 50123c2..067c773 100644
96115 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
96116 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
96117 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
96118 * IPVS LBLCR sysctl table
96119 */
96120
96121 -static ctl_table vs_vars_table[] = {
96122 +static ctl_table_no_const vs_vars_table[] __read_only = {
96123 {
96124 .procname = "lblcr_expiration",
96125 .data = NULL,
96126 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
96127 index f6046d9..4f10cfd 100644
96128 --- a/net/netfilter/ipvs/ip_vs_sync.c
96129 +++ b/net/netfilter/ipvs/ip_vs_sync.c
96130 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
96131 cp = cp->control;
96132 if (cp) {
96133 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96134 - pkts = atomic_add_return(1, &cp->in_pkts);
96135 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96136 else
96137 pkts = sysctl_sync_threshold(ipvs);
96138 ip_vs_sync_conn(net, cp->control, pkts);
96139 @@ -758,7 +758,7 @@ control:
96140 if (!cp)
96141 return;
96142 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96143 - pkts = atomic_add_return(1, &cp->in_pkts);
96144 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96145 else
96146 pkts = sysctl_sync_threshold(ipvs);
96147 goto sloop;
96148 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
96149
96150 if (opt)
96151 memcpy(&cp->in_seq, opt, sizeof(*opt));
96152 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96153 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96154 cp->state = state;
96155 cp->old_state = cp->state;
96156 /*
96157 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
96158 index b75ff64..0c51bbe 100644
96159 --- a/net/netfilter/ipvs/ip_vs_xmit.c
96160 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
96161 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
96162 else
96163 rc = NF_ACCEPT;
96164 /* do not touch skb anymore */
96165 - atomic_inc(&cp->in_pkts);
96166 + atomic_inc_unchecked(&cp->in_pkts);
96167 goto out;
96168 }
96169
96170 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
96171 else
96172 rc = NF_ACCEPT;
96173 /* do not touch skb anymore */
96174 - atomic_inc(&cp->in_pkts);
96175 + atomic_inc_unchecked(&cp->in_pkts);
96176 goto out;
96177 }
96178
96179 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
96180 index 2d3030a..7ba1c0a 100644
96181 --- a/net/netfilter/nf_conntrack_acct.c
96182 +++ b/net/netfilter/nf_conntrack_acct.c
96183 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
96184 #ifdef CONFIG_SYSCTL
96185 static int nf_conntrack_acct_init_sysctl(struct net *net)
96186 {
96187 - struct ctl_table *table;
96188 + ctl_table_no_const *table;
96189
96190 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
96191 GFP_KERNEL);
96192 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
96193 index 0283bae..5febcb0 100644
96194 --- a/net/netfilter/nf_conntrack_core.c
96195 +++ b/net/netfilter/nf_conntrack_core.c
96196 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
96197 #define DYING_NULLS_VAL ((1<<30)+1)
96198 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
96199
96200 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96201 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
96202 +#endif
96203 +
96204 int nf_conntrack_init_net(struct net *net)
96205 {
96206 int ret;
96207 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
96208 goto err_stat;
96209 }
96210
96211 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96212 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
96213 +#else
96214 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
96215 +#endif
96216 if (!net->ct.slabname) {
96217 ret = -ENOMEM;
96218 goto err_slabname;
96219 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
96220 index 1df1761..ce8b88a 100644
96221 --- a/net/netfilter/nf_conntrack_ecache.c
96222 +++ b/net/netfilter/nf_conntrack_ecache.c
96223 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
96224 #ifdef CONFIG_SYSCTL
96225 static int nf_conntrack_event_init_sysctl(struct net *net)
96226 {
96227 - struct ctl_table *table;
96228 + ctl_table_no_const *table;
96229
96230 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
96231 GFP_KERNEL);
96232 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
96233 index 974a2a4..52cc6ff 100644
96234 --- a/net/netfilter/nf_conntrack_helper.c
96235 +++ b/net/netfilter/nf_conntrack_helper.c
96236 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
96237
96238 static int nf_conntrack_helper_init_sysctl(struct net *net)
96239 {
96240 - struct ctl_table *table;
96241 + ctl_table_no_const *table;
96242
96243 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
96244 GFP_KERNEL);
96245 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
96246 index 0ab9636..cea3c6a 100644
96247 --- a/net/netfilter/nf_conntrack_proto.c
96248 +++ b/net/netfilter/nf_conntrack_proto.c
96249 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
96250
96251 static void
96252 nf_ct_unregister_sysctl(struct ctl_table_header **header,
96253 - struct ctl_table **table,
96254 + ctl_table_no_const **table,
96255 unsigned int users)
96256 {
96257 if (users > 0)
96258 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
96259 index a99b6c3..cb372f9 100644
96260 --- a/net/netfilter/nf_conntrack_proto_dccp.c
96261 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
96262 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96263 const char *msg;
96264 u_int8_t state;
96265
96266 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96267 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96268 BUG_ON(dh == NULL);
96269
96270 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
96271 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96272 out_invalid:
96273 if (LOG_INVALID(net, IPPROTO_DCCP))
96274 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
96275 - NULL, msg);
96276 + NULL, "%s", msg);
96277 return false;
96278 }
96279
96280 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
96281 u_int8_t type, old_state, new_state;
96282 enum ct_dccp_roles role;
96283
96284 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96285 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96286 BUG_ON(dh == NULL);
96287 type = dh->dccph_type;
96288
96289 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96290 unsigned int cscov;
96291 const char *msg;
96292
96293 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96294 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96295 if (dh == NULL) {
96296 msg = "nf_ct_dccp: short packet ";
96297 goto out_invalid;
96298 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96299
96300 out_invalid:
96301 if (LOG_INVALID(net, IPPROTO_DCCP))
96302 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
96303 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
96304 return -NF_ACCEPT;
96305 }
96306
96307 diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
96308 index 4d4d8f1..e0f9a32 100644
96309 --- a/net/netfilter/nf_conntrack_proto_tcp.c
96310 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
96311 @@ -526,7 +526,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
96312 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
96313 __u32 seq, ack, sack, end, win, swin;
96314 s16 receiver_offset;
96315 - bool res;
96316 + bool res, in_recv_win;
96317
96318 /*
96319 * Get the required data from the packet.
96320 @@ -649,14 +649,18 @@ static bool tcp_in_window(const struct nf_conn *ct,
96321 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
96322 receiver->td_scale);
96323
96324 + /* Is the ending sequence in the receive window (if available)? */
96325 + in_recv_win = !receiver->td_maxwin ||
96326 + after(end, sender->td_end - receiver->td_maxwin - 1);
96327 +
96328 pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
96329 before(seq, sender->td_maxend + 1),
96330 - after(end, sender->td_end - receiver->td_maxwin - 1),
96331 + (in_recv_win ? 1 : 0),
96332 before(sack, receiver->td_end + 1),
96333 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1));
96334
96335 if (before(seq, sender->td_maxend + 1) &&
96336 - after(end, sender->td_end - receiver->td_maxwin - 1) &&
96337 + in_recv_win &&
96338 before(sack, receiver->td_end + 1) &&
96339 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) {
96340 /*
96341 @@ -725,7 +729,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
96342 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
96343 "nf_ct_tcp: %s ",
96344 before(seq, sender->td_maxend + 1) ?
96345 - after(end, sender->td_end - receiver->td_maxwin - 1) ?
96346 + in_recv_win ?
96347 before(sack, receiver->td_end + 1) ?
96348 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG"
96349 : "ACK is under the lower bound (possible overly delayed ACK)"
96350 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
96351 index bd700b4..4a3dc61 100644
96352 --- a/net/netfilter/nf_conntrack_standalone.c
96353 +++ b/net/netfilter/nf_conntrack_standalone.c
96354 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
96355
96356 static int nf_conntrack_standalone_init_sysctl(struct net *net)
96357 {
96358 - struct ctl_table *table;
96359 + ctl_table_no_const *table;
96360
96361 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
96362 GFP_KERNEL);
96363 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
96364 index 902fb0a..87f7fdb 100644
96365 --- a/net/netfilter/nf_conntrack_timestamp.c
96366 +++ b/net/netfilter/nf_conntrack_timestamp.c
96367 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
96368 #ifdef CONFIG_SYSCTL
96369 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
96370 {
96371 - struct ctl_table *table;
96372 + ctl_table_no_const *table;
96373
96374 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
96375 GFP_KERNEL);
96376 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
96377 index 3b18dd1..f79e0ca 100644
96378 --- a/net/netfilter/nf_log.c
96379 +++ b/net/netfilter/nf_log.c
96380 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
96381
96382 #ifdef CONFIG_SYSCTL
96383 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
96384 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
96385 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
96386
96387 static int nf_log_proc_dostring(ctl_table *table, int write,
96388 void __user *buffer, size_t *lenp, loff_t *ppos)
96389 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
96390 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
96391 mutex_unlock(&nf_log_mutex);
96392 } else {
96393 + ctl_table_no_const nf_log_table = *table;
96394 +
96395 mutex_lock(&nf_log_mutex);
96396 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
96397 lockdep_is_held(&nf_log_mutex));
96398 if (!logger)
96399 - table->data = "NONE";
96400 + nf_log_table.data = "NONE";
96401 else
96402 - table->data = logger->name;
96403 - r = proc_dostring(table, write, buffer, lenp, ppos);
96404 + nf_log_table.data = logger->name;
96405 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
96406 mutex_unlock(&nf_log_mutex);
96407 }
96408
96409 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
96410 index f042ae5..30ea486 100644
96411 --- a/net/netfilter/nf_sockopt.c
96412 +++ b/net/netfilter/nf_sockopt.c
96413 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
96414 }
96415 }
96416
96417 - list_add(&reg->list, &nf_sockopts);
96418 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
96419 out:
96420 mutex_unlock(&nf_sockopt_mutex);
96421 return ret;
96422 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
96423 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
96424 {
96425 mutex_lock(&nf_sockopt_mutex);
96426 - list_del(&reg->list);
96427 + pax_list_del((struct list_head *)&reg->list);
96428 mutex_unlock(&nf_sockopt_mutex);
96429 }
96430 EXPORT_SYMBOL(nf_unregister_sockopt);
96431 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
96432 index 962e979..e46f350 100644
96433 --- a/net/netfilter/nfnetlink_log.c
96434 +++ b/net/netfilter/nfnetlink_log.c
96435 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
96436 struct nfnl_log_net {
96437 spinlock_t instances_lock;
96438 struct hlist_head instance_table[INSTANCE_BUCKETS];
96439 - atomic_t global_seq;
96440 + atomic_unchecked_t global_seq;
96441 };
96442
96443 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
96444 @@ -419,6 +419,7 @@ __build_packet_message(struct nfnl_log_net *log,
96445 nfmsg->version = NFNETLINK_V0;
96446 nfmsg->res_id = htons(inst->group_num);
96447
96448 + memset(&pmsg, 0, sizeof(pmsg));
96449 pmsg.hw_protocol = skb->protocol;
96450 pmsg.hook = hooknum;
96451
96452 @@ -498,7 +499,10 @@ __build_packet_message(struct nfnl_log_net *log,
96453 if (indev && skb->dev &&
96454 skb->mac_header != skb->network_header) {
96455 struct nfulnl_msg_packet_hw phw;
96456 - int len = dev_parse_header(skb, phw.hw_addr);
96457 + int len;
96458 +
96459 + memset(&phw, 0, sizeof(phw));
96460 + len = dev_parse_header(skb, phw.hw_addr);
96461 if (len > 0) {
96462 phw.hw_addrlen = htons(len);
96463 if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
96464 @@ -559,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
96465 /* global sequence number */
96466 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
96467 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
96468 - htonl(atomic_inc_return(&log->global_seq))))
96469 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
96470 goto nla_put_failure;
96471
96472 if (data_len) {
96473 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
96474 index 5352b2d..e0083ce 100644
96475 --- a/net/netfilter/nfnetlink_queue_core.c
96476 +++ b/net/netfilter/nfnetlink_queue_core.c
96477 @@ -444,7 +444,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
96478 if (indev && entskb->dev &&
96479 entskb->mac_header != entskb->network_header) {
96480 struct nfqnl_msg_packet_hw phw;
96481 - int len = dev_parse_header(entskb, phw.hw_addr);
96482 + int len;
96483 +
96484 + memset(&phw, 0, sizeof(phw));
96485 + len = dev_parse_header(entskb, phw.hw_addr);
96486 if (len) {
96487 phw.hw_addrlen = htons(len);
96488 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
96489 diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
96490 index 7011c71..6113cc7 100644
96491 --- a/net/netfilter/xt_TCPMSS.c
96492 +++ b/net/netfilter/xt_TCPMSS.c
96493 @@ -52,7 +52,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96494 {
96495 const struct xt_tcpmss_info *info = par->targinfo;
96496 struct tcphdr *tcph;
96497 - unsigned int tcplen, i;
96498 + int len, tcp_hdrlen;
96499 + unsigned int i;
96500 __be16 oldval;
96501 u16 newmss;
96502 u8 *opt;
96503 @@ -64,11 +65,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96504 if (!skb_make_writable(skb, skb->len))
96505 return -1;
96506
96507 - tcplen = skb->len - tcphoff;
96508 + len = skb->len - tcphoff;
96509 + if (len < (int)sizeof(struct tcphdr))
96510 + return -1;
96511 +
96512 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
96513 + tcp_hdrlen = tcph->doff * 4;
96514
96515 - /* Header cannot be larger than the packet */
96516 - if (tcplen < tcph->doff*4)
96517 + if (len < tcp_hdrlen)
96518 return -1;
96519
96520 if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
96521 @@ -87,9 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96522 newmss = info->mss;
96523
96524 opt = (u_int8_t *)tcph;
96525 - for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
96526 - if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
96527 - opt[i+1] == TCPOLEN_MSS) {
96528 + for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
96529 + if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
96530 u_int16_t oldmss;
96531
96532 oldmss = (opt[i+2] << 8) | opt[i+3];
96533 @@ -112,9 +115,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96534 }
96535
96536 /* There is data after the header so the option can't be added
96537 - without moving it, and doing so may make the SYN packet
96538 - itself too large. Accept the packet unmodified instead. */
96539 - if (tcplen > tcph->doff*4)
96540 + * without moving it, and doing so may make the SYN packet
96541 + * itself too large. Accept the packet unmodified instead.
96542 + */
96543 + if (len > tcp_hdrlen)
96544 return 0;
96545
96546 /*
96547 @@ -143,10 +147,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96548 newmss = min(newmss, (u16)1220);
96549
96550 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
96551 - memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
96552 + memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
96553
96554 inet_proto_csum_replace2(&tcph->check, skb,
96555 - htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
96556 + htons(len), htons(len + TCPOLEN_MSS), 1);
96557 opt[0] = TCPOPT_MSS;
96558 opt[1] = TCPOLEN_MSS;
96559 opt[2] = (newmss & 0xff00) >> 8;
96560 diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
96561 index b68fa19..625fa1d 100644
96562 --- a/net/netfilter/xt_TCPOPTSTRIP.c
96563 +++ b/net/netfilter/xt_TCPOPTSTRIP.c
96564 @@ -38,7 +38,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
96565 struct tcphdr *tcph;
96566 u_int16_t n, o;
96567 u_int8_t *opt;
96568 - int len;
96569 + int len, tcp_hdrlen;
96570
96571 /* This is a fragment, no TCP header is available */
96572 if (par->fragoff != 0)
96573 @@ -52,7 +52,9 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
96574 return NF_DROP;
96575
96576 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
96577 - if (tcph->doff * 4 > len)
96578 + tcp_hdrlen = tcph->doff * 4;
96579 +
96580 + if (len < tcp_hdrlen)
96581 return NF_DROP;
96582
96583 opt = (u_int8_t *)tcph;
96584 @@ -61,10 +63,10 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
96585 * Walk through all TCP options - if we find some option to remove,
96586 * set all octets to %TCPOPT_NOP and adjust checksum.
96587 */
96588 - for (i = sizeof(struct tcphdr); i < tcp_hdrlen(skb); i += optl) {
96589 + for (i = sizeof(struct tcphdr); i < tcp_hdrlen - 1; i += optl) {
96590 optl = optlen(opt, i);
96591
96592 - if (i + optl > tcp_hdrlen(skb))
96593 + if (i + optl > tcp_hdrlen)
96594 break;
96595
96596 if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i]))
96597 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
96598 new file mode 100644
96599 index 0000000..c566332
96600 --- /dev/null
96601 +++ b/net/netfilter/xt_gradm.c
96602 @@ -0,0 +1,51 @@
96603 +/*
96604 + * gradm match for netfilter
96605 + * Copyright © Zbigniew Krzystolik, 2010
96606 + *
96607 + * This program is free software; you can redistribute it and/or modify
96608 + * it under the terms of the GNU General Public License; either version
96609 + * 2 or 3 as published by the Free Software Foundation.
96610 + */
96611 +#include <linux/module.h>
96612 +#include <linux/moduleparam.h>
96613 +#include <linux/skbuff.h>
96614 +#include <linux/netfilter/x_tables.h>
96615 +#include <linux/grsecurity.h>
96616 +#include <linux/netfilter/xt_gradm.h>
96617 +
96618 +static bool
96619 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
96620 +{
96621 + const struct xt_gradm_mtinfo *info = par->matchinfo;
96622 + bool retval = false;
96623 + if (gr_acl_is_enabled())
96624 + retval = true;
96625 + return retval ^ info->invflags;
96626 +}
96627 +
96628 +static struct xt_match gradm_mt_reg __read_mostly = {
96629 + .name = "gradm",
96630 + .revision = 0,
96631 + .family = NFPROTO_UNSPEC,
96632 + .match = gradm_mt,
96633 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
96634 + .me = THIS_MODULE,
96635 +};
96636 +
96637 +static int __init gradm_mt_init(void)
96638 +{
96639 + return xt_register_match(&gradm_mt_reg);
96640 +}
96641 +
96642 +static void __exit gradm_mt_exit(void)
96643 +{
96644 + xt_unregister_match(&gradm_mt_reg);
96645 +}
96646 +
96647 +module_init(gradm_mt_init);
96648 +module_exit(gradm_mt_exit);
96649 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
96650 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
96651 +MODULE_LICENSE("GPL");
96652 +MODULE_ALIAS("ipt_gradm");
96653 +MODULE_ALIAS("ip6t_gradm");
96654 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
96655 index 4fe4fb4..87a89e5 100644
96656 --- a/net/netfilter/xt_statistic.c
96657 +++ b/net/netfilter/xt_statistic.c
96658 @@ -19,7 +19,7 @@
96659 #include <linux/module.h>
96660
96661 struct xt_statistic_priv {
96662 - atomic_t count;
96663 + atomic_unchecked_t count;
96664 } ____cacheline_aligned_in_smp;
96665
96666 MODULE_LICENSE("GPL");
96667 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
96668 break;
96669 case XT_STATISTIC_MODE_NTH:
96670 do {
96671 - oval = atomic_read(&info->master->count);
96672 + oval = atomic_read_unchecked(&info->master->count);
96673 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
96674 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
96675 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
96676 if (nval == 0)
96677 ret = !ret;
96678 break;
96679 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
96680 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
96681 if (info->master == NULL)
96682 return -ENOMEM;
96683 - atomic_set(&info->master->count, info->u.nth.count);
96684 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
96685
96686 return 0;
96687 }
96688 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
96689 index 57ee84d..8b99cf5 100644
96690 --- a/net/netlink/af_netlink.c
96691 +++ b/net/netlink/af_netlink.c
96692 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
96693 sk->sk_error_report(sk);
96694 }
96695 }
96696 - atomic_inc(&sk->sk_drops);
96697 + atomic_inc_unchecked(&sk->sk_drops);
96698 }
96699
96700 static void netlink_rcv_wake(struct sock *sk)
96701 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
96702 sk_wmem_alloc_get(s),
96703 nlk->cb,
96704 atomic_read(&s->sk_refcnt),
96705 - atomic_read(&s->sk_drops),
96706 + atomic_read_unchecked(&s->sk_drops),
96707 sock_i_ino(s)
96708 );
96709
96710 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
96711 index 1076fe1..f190285 100644
96712 --- a/net/netlink/genetlink.c
96713 +++ b/net/netlink/genetlink.c
96714 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
96715 goto errout;
96716 }
96717
96718 + pax_open_kernel();
96719 if (ops->dumpit)
96720 - ops->flags |= GENL_CMD_CAP_DUMP;
96721 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
96722 if (ops->doit)
96723 - ops->flags |= GENL_CMD_CAP_DO;
96724 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
96725 if (ops->policy)
96726 - ops->flags |= GENL_CMD_CAP_HASPOL;
96727 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
96728 + pax_close_kernel();
96729
96730 genl_lock_all();
96731 - list_add_tail(&ops->ops_list, &family->ops_list);
96732 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
96733 genl_unlock_all();
96734
96735 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
96736 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
96737 err = 0;
96738 errout:
96739 return err;
96740 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
96741 genl_lock_all();
96742 list_for_each_entry(rc, &family->ops_list, ops_list) {
96743 if (rc == ops) {
96744 - list_del(&ops->ops_list);
96745 + pax_list_del((struct list_head *)&ops->ops_list);
96746 genl_unlock_all();
96747 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
96748 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
96749 return 0;
96750 }
96751 }
96752 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
96753 index ec0c80f..41e1830 100644
96754 --- a/net/netrom/af_netrom.c
96755 +++ b/net/netrom/af_netrom.c
96756 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
96757 *uaddr_len = sizeof(struct full_sockaddr_ax25);
96758 } else {
96759 sax->fsa_ax25.sax25_family = AF_NETROM;
96760 - sax->fsa_ax25.sax25_ndigis = 0;
96761 sax->fsa_ax25.sax25_call = nr->source_addr;
96762 *uaddr_len = sizeof(struct sockaddr_ax25);
96763 }
96764 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
96765 index 20a1bd0..bb8f1c1 100644
96766 --- a/net/packet/af_packet.c
96767 +++ b/net/packet/af_packet.c
96768 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96769
96770 spin_lock(&sk->sk_receive_queue.lock);
96771 po->stats.stats1.tp_packets++;
96772 - skb->dropcount = atomic_read(&sk->sk_drops);
96773 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
96774 __skb_queue_tail(&sk->sk_receive_queue, skb);
96775 spin_unlock(&sk->sk_receive_queue.lock);
96776 sk->sk_data_ready(sk, skb->len);
96777 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96778 drop_n_acct:
96779 spin_lock(&sk->sk_receive_queue.lock);
96780 po->stats.stats1.tp_drops++;
96781 - atomic_inc(&sk->sk_drops);
96782 + atomic_inc_unchecked(&sk->sk_drops);
96783 spin_unlock(&sk->sk_receive_queue.lock);
96784
96785 drop_n_restore:
96786 @@ -2640,6 +2640,7 @@ out:
96787
96788 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
96789 {
96790 + struct sock_extended_err ee;
96791 struct sock_exterr_skb *serr;
96792 struct sk_buff *skb, *skb2;
96793 int copied, err;
96794 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
96795 sock_recv_timestamp(msg, sk, skb);
96796
96797 serr = SKB_EXT_ERR(skb);
96798 + ee = serr->ee;
96799 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
96800 - sizeof(serr->ee), &serr->ee);
96801 + sizeof ee, &ee);
96802
96803 msg->msg_flags |= MSG_ERRQUEUE;
96804 err = copied;
96805 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96806 case PACKET_HDRLEN:
96807 if (len > sizeof(int))
96808 len = sizeof(int);
96809 - if (copy_from_user(&val, optval, len))
96810 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96811 return -EFAULT;
96812 switch (val) {
96813 case TPACKET_V1:
96814 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96815 len = lv;
96816 if (put_user(len, optlen))
96817 return -EFAULT;
96818 - if (copy_to_user(optval, data, len))
96819 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96820 return -EFAULT;
96821 return 0;
96822 }
96823 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
96824 index 5a940db..d6a502d 100644
96825 --- a/net/phonet/af_phonet.c
96826 +++ b/net/phonet/af_phonet.c
96827 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
96828 {
96829 int err = 0;
96830
96831 - if (protocol >= PHONET_NPROTO)
96832 + if (protocol < 0 || protocol >= PHONET_NPROTO)
96833 return -EINVAL;
96834
96835 err = proto_register(pp->prot, 1);
96836 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96837 index e774117..900b8b7 100644
96838 --- a/net/phonet/pep.c
96839 +++ b/net/phonet/pep.c
96840 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96841
96842 case PNS_PEP_CTRL_REQ:
96843 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96844 - atomic_inc(&sk->sk_drops);
96845 + atomic_inc_unchecked(&sk->sk_drops);
96846 break;
96847 }
96848 __skb_pull(skb, 4);
96849 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96850 }
96851
96852 if (pn->rx_credits == 0) {
96853 - atomic_inc(&sk->sk_drops);
96854 + atomic_inc_unchecked(&sk->sk_drops);
96855 err = -ENOBUFS;
96856 break;
96857 }
96858 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96859 }
96860
96861 if (pn->rx_credits == 0) {
96862 - atomic_inc(&sk->sk_drops);
96863 + atomic_inc_unchecked(&sk->sk_drops);
96864 err = NET_RX_DROP;
96865 break;
96866 }
96867 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96868 index 1afd138..0b42453 100644
96869 --- a/net/phonet/socket.c
96870 +++ b/net/phonet/socket.c
96871 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96872 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96873 sock_i_ino(sk),
96874 atomic_read(&sk->sk_refcnt), sk,
96875 - atomic_read(&sk->sk_drops), &len);
96876 + atomic_read_unchecked(&sk->sk_drops), &len);
96877 }
96878 seq_printf(seq, "%*s\n", 127 - len, "");
96879 return 0;
96880 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96881 index d6bbbbd..61561e4 100644
96882 --- a/net/phonet/sysctl.c
96883 +++ b/net/phonet/sysctl.c
96884 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
96885 {
96886 int ret;
96887 int range[2] = {local_port_range[0], local_port_range[1]};
96888 - ctl_table tmp = {
96889 + ctl_table_no_const tmp = {
96890 .data = &range,
96891 .maxlen = sizeof(range),
96892 .mode = table->mode,
96893 diff --git a/net/rds/cong.c b/net/rds/cong.c
96894 index e5b65ac..f3b6fb7 100644
96895 --- a/net/rds/cong.c
96896 +++ b/net/rds/cong.c
96897 @@ -78,7 +78,7 @@
96898 * finds that the saved generation number is smaller than the global generation
96899 * number, it wakes up the process.
96900 */
96901 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96902 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96903
96904 /*
96905 * Congestion monitoring
96906 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96907 rdsdebug("waking map %p for %pI4\n",
96908 map, &map->m_addr);
96909 rds_stats_inc(s_cong_update_received);
96910 - atomic_inc(&rds_cong_generation);
96911 + atomic_inc_unchecked(&rds_cong_generation);
96912 if (waitqueue_active(&map->m_waitq))
96913 wake_up(&map->m_waitq);
96914 if (waitqueue_active(&rds_poll_waitq))
96915 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96916
96917 int rds_cong_updated_since(unsigned long *recent)
96918 {
96919 - unsigned long gen = atomic_read(&rds_cong_generation);
96920 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96921
96922 if (likely(*recent == gen))
96923 return 0;
96924 diff --git a/net/rds/ib.h b/net/rds/ib.h
96925 index 7280ab8..e04f4ea 100644
96926 --- a/net/rds/ib.h
96927 +++ b/net/rds/ib.h
96928 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96929 /* sending acks */
96930 unsigned long i_ack_flags;
96931 #ifdef KERNEL_HAS_ATOMIC64
96932 - atomic64_t i_ack_next; /* next ACK to send */
96933 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96934 #else
96935 spinlock_t i_ack_lock; /* protect i_ack_next */
96936 u64 i_ack_next; /* next ACK to send */
96937 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96938 index 31b74f5..dc1fbfa 100644
96939 --- a/net/rds/ib_cm.c
96940 +++ b/net/rds/ib_cm.c
96941 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96942 /* Clear the ACK state */
96943 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96944 #ifdef KERNEL_HAS_ATOMIC64
96945 - atomic64_set(&ic->i_ack_next, 0);
96946 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96947 #else
96948 ic->i_ack_next = 0;
96949 #endif
96950 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96951 index 8eb9501..0c386ff 100644
96952 --- a/net/rds/ib_recv.c
96953 +++ b/net/rds/ib_recv.c
96954 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96955 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96956 int ack_required)
96957 {
96958 - atomic64_set(&ic->i_ack_next, seq);
96959 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96960 if (ack_required) {
96961 smp_mb__before_clear_bit();
96962 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96963 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96964 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96965 smp_mb__after_clear_bit();
96966
96967 - return atomic64_read(&ic->i_ack_next);
96968 + return atomic64_read_unchecked(&ic->i_ack_next);
96969 }
96970 #endif
96971
96972 diff --git a/net/rds/iw.h b/net/rds/iw.h
96973 index 04ce3b1..48119a6 100644
96974 --- a/net/rds/iw.h
96975 +++ b/net/rds/iw.h
96976 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96977 /* sending acks */
96978 unsigned long i_ack_flags;
96979 #ifdef KERNEL_HAS_ATOMIC64
96980 - atomic64_t i_ack_next; /* next ACK to send */
96981 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96982 #else
96983 spinlock_t i_ack_lock; /* protect i_ack_next */
96984 u64 i_ack_next; /* next ACK to send */
96985 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96986 index a91e1db..cf3053f 100644
96987 --- a/net/rds/iw_cm.c
96988 +++ b/net/rds/iw_cm.c
96989 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96990 /* Clear the ACK state */
96991 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96992 #ifdef KERNEL_HAS_ATOMIC64
96993 - atomic64_set(&ic->i_ack_next, 0);
96994 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96995 #else
96996 ic->i_ack_next = 0;
96997 #endif
96998 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96999 index 4503335..db566b4 100644
97000 --- a/net/rds/iw_recv.c
97001 +++ b/net/rds/iw_recv.c
97002 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
97003 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
97004 int ack_required)
97005 {
97006 - atomic64_set(&ic->i_ack_next, seq);
97007 + atomic64_set_unchecked(&ic->i_ack_next, seq);
97008 if (ack_required) {
97009 smp_mb__before_clear_bit();
97010 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97011 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
97012 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97013 smp_mb__after_clear_bit();
97014
97015 - return atomic64_read(&ic->i_ack_next);
97016 + return atomic64_read_unchecked(&ic->i_ack_next);
97017 }
97018 #endif
97019
97020 diff --git a/net/rds/rds.h b/net/rds/rds.h
97021 index ec1d731..90a3a8d 100644
97022 --- a/net/rds/rds.h
97023 +++ b/net/rds/rds.h
97024 @@ -449,7 +449,7 @@ struct rds_transport {
97025 void (*sync_mr)(void *trans_private, int direction);
97026 void (*free_mr)(void *trans_private, int invalidate);
97027 void (*flush_mrs)(void);
97028 -};
97029 +} __do_const;
97030
97031 struct rds_sock {
97032 struct sock rs_sk;
97033 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
97034 index edac9ef..16bcb98 100644
97035 --- a/net/rds/tcp.c
97036 +++ b/net/rds/tcp.c
97037 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
97038 int val = 1;
97039
97040 set_fs(KERNEL_DS);
97041 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
97042 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
97043 sizeof(val));
97044 set_fs(oldfs);
97045 }
97046 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
97047 index 81cf5a4..b5826ff 100644
97048 --- a/net/rds/tcp_send.c
97049 +++ b/net/rds/tcp_send.c
97050 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
97051
97052 oldfs = get_fs();
97053 set_fs(KERNEL_DS);
97054 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
97055 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
97056 sizeof(val));
97057 set_fs(oldfs);
97058 }
97059 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
97060 index e61aa60..f07cc89 100644
97061 --- a/net/rxrpc/af_rxrpc.c
97062 +++ b/net/rxrpc/af_rxrpc.c
97063 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
97064 __be32 rxrpc_epoch;
97065
97066 /* current debugging ID */
97067 -atomic_t rxrpc_debug_id;
97068 +atomic_unchecked_t rxrpc_debug_id;
97069
97070 /* count of skbs currently in use */
97071 atomic_t rxrpc_n_skbs;
97072 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
97073 index e4d9cbc..b229649 100644
97074 --- a/net/rxrpc/ar-ack.c
97075 +++ b/net/rxrpc/ar-ack.c
97076 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97077
97078 _enter("{%d,%d,%d,%d},",
97079 call->acks_hard, call->acks_unacked,
97080 - atomic_read(&call->sequence),
97081 + atomic_read_unchecked(&call->sequence),
97082 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
97083
97084 stop = 0;
97085 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97086
97087 /* each Tx packet has a new serial number */
97088 sp->hdr.serial =
97089 - htonl(atomic_inc_return(&call->conn->serial));
97090 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
97091
97092 hdr = (struct rxrpc_header *) txb->head;
97093 hdr->serial = sp->hdr.serial;
97094 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
97095 */
97096 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
97097 {
97098 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
97099 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
97100 }
97101
97102 /*
97103 @@ -629,7 +629,7 @@ process_further:
97104
97105 latest = ntohl(sp->hdr.serial);
97106 hard = ntohl(ack.firstPacket);
97107 - tx = atomic_read(&call->sequence);
97108 + tx = atomic_read_unchecked(&call->sequence);
97109
97110 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97111 latest,
97112 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
97113 goto maybe_reschedule;
97114
97115 send_ACK_with_skew:
97116 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
97117 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
97118 ntohl(ack.serial));
97119 send_ACK:
97120 mtu = call->conn->trans->peer->if_mtu;
97121 @@ -1173,7 +1173,7 @@ send_ACK:
97122 ackinfo.rxMTU = htonl(5692);
97123 ackinfo.jumbo_max = htonl(4);
97124
97125 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97126 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97127 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97128 ntohl(hdr.serial),
97129 ntohs(ack.maxSkew),
97130 @@ -1191,7 +1191,7 @@ send_ACK:
97131 send_message:
97132 _debug("send message");
97133
97134 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97135 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97136 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
97137 send_message_2:
97138
97139 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
97140 index a3bbb36..3341fb9 100644
97141 --- a/net/rxrpc/ar-call.c
97142 +++ b/net/rxrpc/ar-call.c
97143 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
97144 spin_lock_init(&call->lock);
97145 rwlock_init(&call->state_lock);
97146 atomic_set(&call->usage, 1);
97147 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
97148 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97149 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
97150
97151 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
97152 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
97153 index 4106ca9..a338d7a 100644
97154 --- a/net/rxrpc/ar-connection.c
97155 +++ b/net/rxrpc/ar-connection.c
97156 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
97157 rwlock_init(&conn->lock);
97158 spin_lock_init(&conn->state_lock);
97159 atomic_set(&conn->usage, 1);
97160 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
97161 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97162 conn->avail_calls = RXRPC_MAXCALLS;
97163 conn->size_align = 4;
97164 conn->header_size = sizeof(struct rxrpc_header);
97165 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
97166 index e7ed43a..6afa140 100644
97167 --- a/net/rxrpc/ar-connevent.c
97168 +++ b/net/rxrpc/ar-connevent.c
97169 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
97170
97171 len = iov[0].iov_len + iov[1].iov_len;
97172
97173 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97174 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97175 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
97176
97177 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97178 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
97179 index 529572f..c758ca7 100644
97180 --- a/net/rxrpc/ar-input.c
97181 +++ b/net/rxrpc/ar-input.c
97182 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
97183 /* track the latest serial number on this connection for ACK packet
97184 * information */
97185 serial = ntohl(sp->hdr.serial);
97186 - hi_serial = atomic_read(&call->conn->hi_serial);
97187 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
97188 while (serial > hi_serial)
97189 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
97190 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
97191 serial);
97192
97193 /* request ACK generation for any ACK or DATA packet that requests
97194 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
97195 index a693aca..81e7293 100644
97196 --- a/net/rxrpc/ar-internal.h
97197 +++ b/net/rxrpc/ar-internal.h
97198 @@ -272,8 +272,8 @@ struct rxrpc_connection {
97199 int error; /* error code for local abort */
97200 int debug_id; /* debug ID for printks */
97201 unsigned int call_counter; /* call ID counter */
97202 - atomic_t serial; /* packet serial number counter */
97203 - atomic_t hi_serial; /* highest serial number received */
97204 + atomic_unchecked_t serial; /* packet serial number counter */
97205 + atomic_unchecked_t hi_serial; /* highest serial number received */
97206 u8 avail_calls; /* number of calls available */
97207 u8 size_align; /* data size alignment (for security) */
97208 u8 header_size; /* rxrpc + security header size */
97209 @@ -346,7 +346,7 @@ struct rxrpc_call {
97210 spinlock_t lock;
97211 rwlock_t state_lock; /* lock for state transition */
97212 atomic_t usage;
97213 - atomic_t sequence; /* Tx data packet sequence counter */
97214 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
97215 u32 abort_code; /* local/remote abort code */
97216 enum { /* current state of call */
97217 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
97218 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
97219 */
97220 extern atomic_t rxrpc_n_skbs;
97221 extern __be32 rxrpc_epoch;
97222 -extern atomic_t rxrpc_debug_id;
97223 +extern atomic_unchecked_t rxrpc_debug_id;
97224 extern struct workqueue_struct *rxrpc_workqueue;
97225
97226 /*
97227 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
97228 index 87f7135..74d3703 100644
97229 --- a/net/rxrpc/ar-local.c
97230 +++ b/net/rxrpc/ar-local.c
97231 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
97232 spin_lock_init(&local->lock);
97233 rwlock_init(&local->services_lock);
97234 atomic_set(&local->usage, 1);
97235 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
97236 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97237 memcpy(&local->srx, srx, sizeof(*srx));
97238 }
97239
97240 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
97241 index e1ac183..b43e10e 100644
97242 --- a/net/rxrpc/ar-output.c
97243 +++ b/net/rxrpc/ar-output.c
97244 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
97245 sp->hdr.cid = call->cid;
97246 sp->hdr.callNumber = call->call_id;
97247 sp->hdr.seq =
97248 - htonl(atomic_inc_return(&call->sequence));
97249 + htonl(atomic_inc_return_unchecked(&call->sequence));
97250 sp->hdr.serial =
97251 - htonl(atomic_inc_return(&conn->serial));
97252 + htonl(atomic_inc_return_unchecked(&conn->serial));
97253 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
97254 sp->hdr.userStatus = 0;
97255 sp->hdr.securityIndex = conn->security_ix;
97256 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
97257 index bebaa43..2644591 100644
97258 --- a/net/rxrpc/ar-peer.c
97259 +++ b/net/rxrpc/ar-peer.c
97260 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
97261 INIT_LIST_HEAD(&peer->error_targets);
97262 spin_lock_init(&peer->lock);
97263 atomic_set(&peer->usage, 1);
97264 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
97265 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97266 memcpy(&peer->srx, srx, sizeof(*srx));
97267
97268 rxrpc_assess_MTU_size(peer);
97269 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
97270 index 38047f7..9f48511 100644
97271 --- a/net/rxrpc/ar-proc.c
97272 +++ b/net/rxrpc/ar-proc.c
97273 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
97274 atomic_read(&conn->usage),
97275 rxrpc_conn_states[conn->state],
97276 key_serial(conn->key),
97277 - atomic_read(&conn->serial),
97278 - atomic_read(&conn->hi_serial));
97279 + atomic_read_unchecked(&conn->serial),
97280 + atomic_read_unchecked(&conn->hi_serial));
97281
97282 return 0;
97283 }
97284 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
97285 index 92df566..87ec1bf 100644
97286 --- a/net/rxrpc/ar-transport.c
97287 +++ b/net/rxrpc/ar-transport.c
97288 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
97289 spin_lock_init(&trans->client_lock);
97290 rwlock_init(&trans->conn_lock);
97291 atomic_set(&trans->usage, 1);
97292 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
97293 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97294
97295 if (peer->srx.transport.family == AF_INET) {
97296 switch (peer->srx.transport_type) {
97297 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
97298 index f226709..0e735a8 100644
97299 --- a/net/rxrpc/rxkad.c
97300 +++ b/net/rxrpc/rxkad.c
97301 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
97302
97303 len = iov[0].iov_len + iov[1].iov_len;
97304
97305 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97306 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97307 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
97308
97309 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97310 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
97311
97312 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
97313
97314 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
97315 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97316 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
97317
97318 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
97319 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
97320 index 391a245..296b3d7 100644
97321 --- a/net/sctp/ipv6.c
97322 +++ b/net/sctp/ipv6.c
97323 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
97324 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
97325 };
97326
97327 -static struct sctp_af sctp_af_inet6 = {
97328 +static struct sctp_af sctp_af_inet6 __read_only = {
97329 .sa_family = AF_INET6,
97330 .sctp_xmit = sctp_v6_xmit,
97331 .setsockopt = ipv6_setsockopt,
97332 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
97333 #endif
97334 };
97335
97336 -static struct sctp_pf sctp_pf_inet6 = {
97337 +static struct sctp_pf sctp_pf_inet6 __read_only = {
97338 .event_msgname = sctp_inet6_event_msgname,
97339 .skb_msgname = sctp_inet6_skb_msgname,
97340 .af_supported = sctp_inet6_af_supported,
97341 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
97342
97343 void sctp_v6_pf_exit(void)
97344 {
97345 - list_del(&sctp_af_inet6.list);
97346 + pax_list_del(&sctp_af_inet6.list);
97347 }
97348
97349 /* Initialize IPv6 support and register with socket layer. */
97350 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
97351 index 4e45ee3..e66a031 100644
97352 --- a/net/sctp/proc.c
97353 +++ b/net/sctp/proc.c
97354 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
97355 seq_printf(seq,
97356 "%8pK %8pK %-3d %-3d %-2d %-4d "
97357 "%4d %8d %8d %7d %5lu %-5d %5d ",
97358 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
97359 + assoc, sk,
97360 + sctp_sk(sk)->type, sk->sk_state,
97361 assoc->state, hash,
97362 assoc->assoc_id,
97363 assoc->sndbuf_used,
97364 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
97365 index eaee00c..97c0afd 100644
97366 --- a/net/sctp/protocol.c
97367 +++ b/net/sctp/protocol.c
97368 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
97369 return 0;
97370 }
97371
97372 + pax_open_kernel();
97373 INIT_LIST_HEAD(&af->list);
97374 - list_add_tail(&af->list, &sctp_address_families);
97375 + pax_close_kernel();
97376 + pax_list_add_tail(&af->list, &sctp_address_families);
97377 return 1;
97378 }
97379
97380 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
97381
97382 static struct sctp_af sctp_af_inet;
97383
97384 -static struct sctp_pf sctp_pf_inet = {
97385 +static struct sctp_pf sctp_pf_inet __read_only = {
97386 .event_msgname = sctp_inet_event_msgname,
97387 .skb_msgname = sctp_inet_skb_msgname,
97388 .af_supported = sctp_inet_af_supported,
97389 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
97390 };
97391
97392 /* IPv4 address related functions. */
97393 -static struct sctp_af sctp_af_inet = {
97394 +static struct sctp_af sctp_af_inet __read_only = {
97395 .sa_family = AF_INET,
97396 .sctp_xmit = sctp_v4_xmit,
97397 .setsockopt = ip_setsockopt,
97398 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
97399
97400 static void sctp_v4_pf_exit(void)
97401 {
97402 - list_del(&sctp_af_inet.list);
97403 + pax_list_del(&sctp_af_inet.list);
97404 }
97405
97406 static int sctp_v4_protosw_init(void)
97407 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
97408 index 8aab894..f6b7e7d 100644
97409 --- a/net/sctp/sm_sideeffect.c
97410 +++ b/net/sctp/sm_sideeffect.c
97411 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
97412 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
97413 }
97414
97415 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97416 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97417 NULL,
97418 sctp_generate_t1_cookie_event,
97419 sctp_generate_t1_init_event,
97420 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
97421 index 6abb1ca..1678f8b 100644
97422 --- a/net/sctp/socket.c
97423 +++ b/net/sctp/socket.c
97424 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
97425 {
97426 struct sctp_association *asoc;
97427 struct sctp_ulpevent *event;
97428 + struct sctp_event_subscribe subscribe;
97429
97430 if (optlen > sizeof(struct sctp_event_subscribe))
97431 return -EINVAL;
97432 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
97433 + if (copy_from_user(&subscribe, optval, optlen))
97434 return -EFAULT;
97435 + sctp_sk(sk)->subscribe = subscribe;
97436
97437 /*
97438 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
97439 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
97440 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97441 int __user *optlen)
97442 {
97443 + struct sctp_event_subscribe subscribe;
97444 +
97445 if (len <= 0)
97446 return -EINVAL;
97447 if (len > sizeof(struct sctp_event_subscribe))
97448 len = sizeof(struct sctp_event_subscribe);
97449 if (put_user(len, optlen))
97450 return -EFAULT;
97451 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
97452 + subscribe = sctp_sk(sk)->subscribe;
97453 + if (copy_to_user(optval, &subscribe, len))
97454 return -EFAULT;
97455 return 0;
97456 }
97457 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97458 */
97459 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
97460 {
97461 + __u32 autoclose;
97462 +
97463 /* Applicable to UDP-style socket only */
97464 if (sctp_style(sk, TCP))
97465 return -EOPNOTSUPP;
97466 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
97467 len = sizeof(int);
97468 if (put_user(len, optlen))
97469 return -EFAULT;
97470 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
97471 + autoclose = sctp_sk(sk)->autoclose;
97472 + if (copy_to_user(optval, &autoclose, sizeof(int)))
97473 return -EFAULT;
97474 return 0;
97475 }
97476 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
97477 */
97478 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
97479 {
97480 + struct sctp_initmsg initmsg;
97481 +
97482 if (len < sizeof(struct sctp_initmsg))
97483 return -EINVAL;
97484 len = sizeof(struct sctp_initmsg);
97485 if (put_user(len, optlen))
97486 return -EFAULT;
97487 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
97488 + initmsg = sctp_sk(sk)->initmsg;
97489 + if (copy_to_user(optval, &initmsg, len))
97490 return -EFAULT;
97491 return 0;
97492 }
97493 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
97494 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
97495 if (space_left < addrlen)
97496 return -ENOMEM;
97497 + if (addrlen > sizeof(temp) || addrlen < 0)
97498 + return -EFAULT;
97499 if (copy_to_user(to, &temp, addrlen))
97500 return -EFAULT;
97501 to += addrlen;
97502 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
97503 index bf3c6e8..376d8d0 100644
97504 --- a/net/sctp/sysctl.c
97505 +++ b/net/sctp/sysctl.c
97506 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
97507 {
97508 struct net *net = current->nsproxy->net_ns;
97509 char tmp[8];
97510 - ctl_table tbl;
97511 + ctl_table_no_const tbl;
97512 int ret;
97513 int changed = 0;
97514 char *none = "none";
97515 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
97516
97517 int sctp_sysctl_net_register(struct net *net)
97518 {
97519 - struct ctl_table *table;
97520 + ctl_table_no_const *table;
97521 int i;
97522
97523 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
97524 diff --git a/net/sctp/transport.c b/net/sctp/transport.c
97525 index 098f1d5f..60da2f7 100644
97526 --- a/net/sctp/transport.c
97527 +++ b/net/sctp/transport.c
97528 @@ -178,12 +178,12 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
97529 {
97530 SCTP_ASSERT(transport->dead, "Transport is not dead", return);
97531
97532 - call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
97533 -
97534 sctp_packet_free(&transport->packet);
97535
97536 if (transport->asoc)
97537 sctp_association_put(transport->asoc);
97538 +
97539 + call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
97540 }
97541
97542 /* Start T3_rtx timer if it is not already running and update the heartbeat
97543 diff --git a/net/socket.c b/net/socket.c
97544 index 4ca1526..df83e47 100644
97545 --- a/net/socket.c
97546 +++ b/net/socket.c
97547 @@ -88,6 +88,7 @@
97548 #include <linux/magic.h>
97549 #include <linux/slab.h>
97550 #include <linux/xattr.h>
97551 +#include <linux/in.h>
97552
97553 #include <asm/uaccess.h>
97554 #include <asm/unistd.h>
97555 @@ -105,6 +106,8 @@
97556 #include <linux/sockios.h>
97557 #include <linux/atalk.h>
97558
97559 +#include <linux/grsock.h>
97560 +
97561 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
97562 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
97563 unsigned long nr_segs, loff_t pos);
97564 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
97565 &sockfs_dentry_operations, SOCKFS_MAGIC);
97566 }
97567
97568 -static struct vfsmount *sock_mnt __read_mostly;
97569 +struct vfsmount *sock_mnt __read_mostly;
97570
97571 static struct file_system_type sock_fs_type = {
97572 .name = "sockfs",
97573 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97574 return -EAFNOSUPPORT;
97575 if (type < 0 || type >= SOCK_MAX)
97576 return -EINVAL;
97577 + if (protocol < 0)
97578 + return -EINVAL;
97579
97580 /* Compatibility.
97581
97582 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
97583 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
97584 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
97585
97586 + if(!gr_search_socket(family, type, protocol)) {
97587 + retval = -EACCES;
97588 + goto out;
97589 + }
97590 +
97591 + if (gr_handle_sock_all(family, type, protocol)) {
97592 + retval = -EACCES;
97593 + goto out;
97594 + }
97595 +
97596 retval = sock_create(family, type, protocol, &sock);
97597 if (retval < 0)
97598 goto out;
97599 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97600 if (sock) {
97601 err = move_addr_to_kernel(umyaddr, addrlen, &address);
97602 if (err >= 0) {
97603 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
97604 + err = -EACCES;
97605 + goto error;
97606 + }
97607 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
97608 + if (err)
97609 + goto error;
97610 +
97611 err = security_socket_bind(sock,
97612 (struct sockaddr *)&address,
97613 addrlen);
97614 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97615 (struct sockaddr *)
97616 &address, addrlen);
97617 }
97618 +error:
97619 fput_light(sock->file, fput_needed);
97620 }
97621 return err;
97622 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
97623 if ((unsigned int)backlog > somaxconn)
97624 backlog = somaxconn;
97625
97626 + if (gr_handle_sock_server_other(sock->sk)) {
97627 + err = -EPERM;
97628 + goto error;
97629 + }
97630 +
97631 + err = gr_search_listen(sock);
97632 + if (err)
97633 + goto error;
97634 +
97635 err = security_socket_listen(sock, backlog);
97636 if (!err)
97637 err = sock->ops->listen(sock, backlog);
97638
97639 +error:
97640 fput_light(sock->file, fput_needed);
97641 }
97642 return err;
97643 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97644 newsock->type = sock->type;
97645 newsock->ops = sock->ops;
97646
97647 + if (gr_handle_sock_server_other(sock->sk)) {
97648 + err = -EPERM;
97649 + sock_release(newsock);
97650 + goto out_put;
97651 + }
97652 +
97653 + err = gr_search_accept(sock);
97654 + if (err) {
97655 + sock_release(newsock);
97656 + goto out_put;
97657 + }
97658 +
97659 /*
97660 * We don't need try_module_get here, as the listening socket (sock)
97661 * has the protocol module (sock->ops->owner) held.
97662 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97663 fd_install(newfd, newfile);
97664 err = newfd;
97665
97666 + gr_attach_curr_ip(newsock->sk);
97667 +
97668 out_put:
97669 fput_light(sock->file, fput_needed);
97670 out:
97671 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97672 int, addrlen)
97673 {
97674 struct socket *sock;
97675 + struct sockaddr *sck;
97676 struct sockaddr_storage address;
97677 int err, fput_needed;
97678
97679 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97680 if (err < 0)
97681 goto out_put;
97682
97683 + sck = (struct sockaddr *)&address;
97684 +
97685 + if (gr_handle_sock_client(sck)) {
97686 + err = -EACCES;
97687 + goto out_put;
97688 + }
97689 +
97690 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
97691 + if (err)
97692 + goto out_put;
97693 +
97694 err =
97695 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
97696 if (err)
97697 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
97698 * the protocol.
97699 */
97700
97701 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
97702 +
97703 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
97704 unsigned int, flags, struct sockaddr __user *, addr,
97705 int, addr_len)
97706 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
97707 struct socket *sock;
97708 struct iovec iov;
97709 struct msghdr msg;
97710 - struct sockaddr_storage address;
97711 + struct sockaddr_storage address = { };
97712 int err, err2;
97713 int fput_needed;
97714
97715 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
97716 * checking falls down on this.
97717 */
97718 if (copy_from_user(ctl_buf,
97719 - (void __user __force *)msg_sys->msg_control,
97720 + (void __force_user *)msg_sys->msg_control,
97721 ctl_len))
97722 goto out_freectl;
97723 msg_sys->msg_control = ctl_buf;
97724 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97725 int err, total_len, len;
97726
97727 /* kernel mode address */
97728 - struct sockaddr_storage addr;
97729 + struct sockaddr_storage addr = { };
97730
97731 /* user mode address pointers */
97732 struct sockaddr __user *uaddr;
97733 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97734 * kernel msghdr to use the kernel address space)
97735 */
97736
97737 - uaddr = (__force void __user *)msg_sys->msg_name;
97738 + uaddr = (void __force_user *)msg_sys->msg_name;
97739 uaddr_len = COMPAT_NAMELEN(msg);
97740 if (MSG_CMSG_COMPAT & flags) {
97741 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
97742 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
97743 old_fs = get_fs();
97744 set_fs(KERNEL_DS);
97745 err = dev_ioctl(net, cmd,
97746 - (struct ifreq __user __force *) &kifr);
97747 + (struct ifreq __force_user *) &kifr);
97748 set_fs(old_fs);
97749
97750 return err;
97751 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
97752
97753 old_fs = get_fs();
97754 set_fs(KERNEL_DS);
97755 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
97756 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
97757 set_fs(old_fs);
97758
97759 if (cmd == SIOCGIFMAP && !err) {
97760 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
97761 ret |= __get_user(rtdev, &(ur4->rt_dev));
97762 if (rtdev) {
97763 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
97764 - r4.rt_dev = (char __user __force *)devname;
97765 + r4.rt_dev = (char __force_user *)devname;
97766 devname[15] = 0;
97767 } else
97768 r4.rt_dev = NULL;
97769 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
97770 int __user *uoptlen;
97771 int err;
97772
97773 - uoptval = (char __user __force *) optval;
97774 - uoptlen = (int __user __force *) optlen;
97775 + uoptval = (char __force_user *) optval;
97776 + uoptlen = (int __force_user *) optlen;
97777
97778 set_fs(KERNEL_DS);
97779 if (level == SOL_SOCKET)
97780 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
97781 char __user *uoptval;
97782 int err;
97783
97784 - uoptval = (char __user __force *) optval;
97785 + uoptval = (char __force_user *) optval;
97786
97787 set_fs(KERNEL_DS);
97788 if (level == SOL_SOCKET)
97789 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
97790 index 29b4ba9..f648ae7 100644
97791 --- a/net/sunrpc/auth_gss/svcauth_gss.c
97792 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
97793 @@ -1144,7 +1144,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97794 uint64_t *handle)
97795 {
97796 struct rsc rsci, *rscp = NULL;
97797 - static atomic64_t ctxhctr;
97798 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
97799 long long ctxh;
97800 struct gss_api_mech *gm = NULL;
97801 time_t expiry;
97802 @@ -1155,7 +1155,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97803 status = -ENOMEM;
97804 /* the handle needs to be just a unique id,
97805 * use a static counter */
97806 - ctxh = atomic64_inc_return(&ctxhctr);
97807 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
97808
97809 /* make a copy for the caller */
97810 *handle = ctxh;
97811 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
97812 index 426f8fc..1ef9c32 100644
97813 --- a/net/sunrpc/clnt.c
97814 +++ b/net/sunrpc/clnt.c
97815 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
97816 (RPC_IS_ASYNC(task) ? "async" : "sync"));
97817
97818 /* Increment call count */
97819 - task->tk_msg.rpc_proc->p_count++;
97820 + pax_open_kernel();
97821 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
97822 + pax_close_kernel();
97823 clnt->cl_stats->rpccnt++;
97824 task->tk_action = call_reserve;
97825 }
97826 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
97827 index 5356b12..c0f4c29 100644
97828 --- a/net/sunrpc/sched.c
97829 +++ b/net/sunrpc/sched.c
97830 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
97831 #ifdef RPC_DEBUG
97832 static void rpc_task_set_debuginfo(struct rpc_task *task)
97833 {
97834 - static atomic_t rpc_pid;
97835 + static atomic_unchecked_t rpc_pid;
97836
97837 - task->tk_pid = atomic_inc_return(&rpc_pid);
97838 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
97839 }
97840 #else
97841 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97842 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97843 index 89a588b..678ed90 100644
97844 --- a/net/sunrpc/svc.c
97845 +++ b/net/sunrpc/svc.c
97846 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
97847
97848 __module_get(serv->sv_module);
97849 task = kthread_create_on_node(serv->sv_function, rqstp,
97850 - node, serv->sv_name);
97851 + node, "%s", serv->sv_name);
97852 if (IS_ERR(task)) {
97853 error = PTR_ERR(task);
97854 module_put(serv->sv_module);
97855 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97856 svc_putnl(resv, RPC_SUCCESS);
97857
97858 /* Bump per-procedure stats counter */
97859 - procp->pc_count++;
97860 + pax_open_kernel();
97861 + (*(unsigned int *)&procp->pc_count)++;
97862 + pax_close_kernel();
97863
97864 /* Initialize storage for argp and resp */
97865 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97866 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97867 index 8343737..677025e 100644
97868 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97869 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97870 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97871 static unsigned int min_max_inline = 4096;
97872 static unsigned int max_max_inline = 65536;
97873
97874 -atomic_t rdma_stat_recv;
97875 -atomic_t rdma_stat_read;
97876 -atomic_t rdma_stat_write;
97877 -atomic_t rdma_stat_sq_starve;
97878 -atomic_t rdma_stat_rq_starve;
97879 -atomic_t rdma_stat_rq_poll;
97880 -atomic_t rdma_stat_rq_prod;
97881 -atomic_t rdma_stat_sq_poll;
97882 -atomic_t rdma_stat_sq_prod;
97883 +atomic_unchecked_t rdma_stat_recv;
97884 +atomic_unchecked_t rdma_stat_read;
97885 +atomic_unchecked_t rdma_stat_write;
97886 +atomic_unchecked_t rdma_stat_sq_starve;
97887 +atomic_unchecked_t rdma_stat_rq_starve;
97888 +atomic_unchecked_t rdma_stat_rq_poll;
97889 +atomic_unchecked_t rdma_stat_rq_prod;
97890 +atomic_unchecked_t rdma_stat_sq_poll;
97891 +atomic_unchecked_t rdma_stat_sq_prod;
97892
97893 /* Temporary NFS request map and context caches */
97894 struct kmem_cache *svc_rdma_map_cachep;
97895 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
97896 len -= *ppos;
97897 if (len > *lenp)
97898 len = *lenp;
97899 - if (len && copy_to_user(buffer, str_buf, len))
97900 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97901 return -EFAULT;
97902 *lenp = len;
97903 *ppos += len;
97904 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
97905 {
97906 .procname = "rdma_stat_read",
97907 .data = &rdma_stat_read,
97908 - .maxlen = sizeof(atomic_t),
97909 + .maxlen = sizeof(atomic_unchecked_t),
97910 .mode = 0644,
97911 .proc_handler = read_reset_stat,
97912 },
97913 {
97914 .procname = "rdma_stat_recv",
97915 .data = &rdma_stat_recv,
97916 - .maxlen = sizeof(atomic_t),
97917 + .maxlen = sizeof(atomic_unchecked_t),
97918 .mode = 0644,
97919 .proc_handler = read_reset_stat,
97920 },
97921 {
97922 .procname = "rdma_stat_write",
97923 .data = &rdma_stat_write,
97924 - .maxlen = sizeof(atomic_t),
97925 + .maxlen = sizeof(atomic_unchecked_t),
97926 .mode = 0644,
97927 .proc_handler = read_reset_stat,
97928 },
97929 {
97930 .procname = "rdma_stat_sq_starve",
97931 .data = &rdma_stat_sq_starve,
97932 - .maxlen = sizeof(atomic_t),
97933 + .maxlen = sizeof(atomic_unchecked_t),
97934 .mode = 0644,
97935 .proc_handler = read_reset_stat,
97936 },
97937 {
97938 .procname = "rdma_stat_rq_starve",
97939 .data = &rdma_stat_rq_starve,
97940 - .maxlen = sizeof(atomic_t),
97941 + .maxlen = sizeof(atomic_unchecked_t),
97942 .mode = 0644,
97943 .proc_handler = read_reset_stat,
97944 },
97945 {
97946 .procname = "rdma_stat_rq_poll",
97947 .data = &rdma_stat_rq_poll,
97948 - .maxlen = sizeof(atomic_t),
97949 + .maxlen = sizeof(atomic_unchecked_t),
97950 .mode = 0644,
97951 .proc_handler = read_reset_stat,
97952 },
97953 {
97954 .procname = "rdma_stat_rq_prod",
97955 .data = &rdma_stat_rq_prod,
97956 - .maxlen = sizeof(atomic_t),
97957 + .maxlen = sizeof(atomic_unchecked_t),
97958 .mode = 0644,
97959 .proc_handler = read_reset_stat,
97960 },
97961 {
97962 .procname = "rdma_stat_sq_poll",
97963 .data = &rdma_stat_sq_poll,
97964 - .maxlen = sizeof(atomic_t),
97965 + .maxlen = sizeof(atomic_unchecked_t),
97966 .mode = 0644,
97967 .proc_handler = read_reset_stat,
97968 },
97969 {
97970 .procname = "rdma_stat_sq_prod",
97971 .data = &rdma_stat_sq_prod,
97972 - .maxlen = sizeof(atomic_t),
97973 + .maxlen = sizeof(atomic_unchecked_t),
97974 .mode = 0644,
97975 .proc_handler = read_reset_stat,
97976 },
97977 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97978 index 0ce7552..d074459 100644
97979 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97980 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97981 @@ -501,7 +501,7 @@ next_sge:
97982 svc_rdma_put_context(ctxt, 0);
97983 goto out;
97984 }
97985 - atomic_inc(&rdma_stat_read);
97986 + atomic_inc_unchecked(&rdma_stat_read);
97987
97988 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97989 chl_map->ch[ch_no].count -= read_wr.num_sge;
97990 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97991 dto_q);
97992 list_del_init(&ctxt->dto_q);
97993 } else {
97994 - atomic_inc(&rdma_stat_rq_starve);
97995 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97996 clear_bit(XPT_DATA, &xprt->xpt_flags);
97997 ctxt = NULL;
97998 }
97999 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
98000 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
98001 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
98002 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
98003 - atomic_inc(&rdma_stat_recv);
98004 + atomic_inc_unchecked(&rdma_stat_recv);
98005
98006 /* Build up the XDR from the receive buffers. */
98007 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
98008 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98009 index c1d124d..acfc59e 100644
98010 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98011 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98012 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
98013 write_wr.wr.rdma.remote_addr = to;
98014
98015 /* Post It */
98016 - atomic_inc(&rdma_stat_write);
98017 + atomic_inc_unchecked(&rdma_stat_write);
98018 if (svc_rdma_send(xprt, &write_wr))
98019 goto err;
98020 return 0;
98021 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
98022 index 62e4f9b..dd3f2d7 100644
98023 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
98024 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
98025 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
98026 return;
98027
98028 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
98029 - atomic_inc(&rdma_stat_rq_poll);
98030 + atomic_inc_unchecked(&rdma_stat_rq_poll);
98031
98032 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
98033 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
98034 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
98035 }
98036
98037 if (ctxt)
98038 - atomic_inc(&rdma_stat_rq_prod);
98039 + atomic_inc_unchecked(&rdma_stat_rq_prod);
98040
98041 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
98042 /*
98043 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
98044 return;
98045
98046 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
98047 - atomic_inc(&rdma_stat_sq_poll);
98048 + atomic_inc_unchecked(&rdma_stat_sq_poll);
98049 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
98050 if (wc.status != IB_WC_SUCCESS)
98051 /* Close the transport */
98052 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
98053 }
98054
98055 if (ctxt)
98056 - atomic_inc(&rdma_stat_sq_prod);
98057 + atomic_inc_unchecked(&rdma_stat_sq_prod);
98058 }
98059
98060 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
98061 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
98062 spin_lock_bh(&xprt->sc_lock);
98063 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
98064 spin_unlock_bh(&xprt->sc_lock);
98065 - atomic_inc(&rdma_stat_sq_starve);
98066 + atomic_inc_unchecked(&rdma_stat_sq_starve);
98067
98068 /* See if we can opportunistically reap SQ WR to make room */
98069 sq_cq_reap(xprt);
98070 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
98071 index 9bc6db0..47ac8c0 100644
98072 --- a/net/sysctl_net.c
98073 +++ b/net/sysctl_net.c
98074 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
98075 kgid_t root_gid = make_kgid(net->user_ns, 0);
98076
98077 /* Allow network administrator to have same access as root. */
98078 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
98079 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
98080 uid_eq(root_uid, current_uid())) {
98081 int mode = (table->mode >> 6) & 7;
98082 return (mode << 6) | (mode << 3) | mode;
98083 diff --git a/net/tipc/link.c b/net/tipc/link.c
98084 index a80feee..2bbbe70 100644
98085 --- a/net/tipc/link.c
98086 +++ b/net/tipc/link.c
98087 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
98088 struct tipc_msg fragm_hdr;
98089 struct sk_buff *buf, *buf_chain, *prev;
98090 u32 fragm_crs, fragm_rest, hsz, sect_rest;
98091 - const unchar *sect_crs;
98092 + const unchar __user *sect_crs;
98093 int curr_sect;
98094 u32 fragm_no;
98095
98096 @@ -1242,7 +1242,7 @@ again:
98097
98098 if (!sect_rest) {
98099 sect_rest = msg_sect[++curr_sect].iov_len;
98100 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
98101 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
98102 }
98103
98104 if (sect_rest < fragm_rest)
98105 @@ -1261,7 +1261,7 @@ error:
98106 }
98107 } else
98108 skb_copy_to_linear_data_offset(buf, fragm_crs,
98109 - sect_crs, sz);
98110 + (const void __force_kernel *)sect_crs, sz);
98111 sect_crs += sz;
98112 sect_rest -= sz;
98113 fragm_crs += sz;
98114 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
98115 index f2db8a8..9245aa4 100644
98116 --- a/net/tipc/msg.c
98117 +++ b/net/tipc/msg.c
98118 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
98119 msg_sect[cnt].iov_len);
98120 else
98121 skb_copy_to_linear_data_offset(*buf, pos,
98122 - msg_sect[cnt].iov_base,
98123 + (const void __force_kernel *)msg_sect[cnt].iov_base,
98124 msg_sect[cnt].iov_len);
98125 pos += msg_sect[cnt].iov_len;
98126 }
98127 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
98128 index 6b42d47..2ac24d5 100644
98129 --- a/net/tipc/subscr.c
98130 +++ b/net/tipc/subscr.c
98131 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
98132 {
98133 struct iovec msg_sect;
98134
98135 - msg_sect.iov_base = (void *)&sub->evt;
98136 + msg_sect.iov_base = (void __force_user *)&sub->evt;
98137 msg_sect.iov_len = sizeof(struct tipc_event);
98138
98139 sub->evt.event = htohl(event, sub->swap);
98140 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
98141 index 826e099..4fa8c93 100644
98142 --- a/net/unix/af_unix.c
98143 +++ b/net/unix/af_unix.c
98144 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
98145 err = -ECONNREFUSED;
98146 if (!S_ISSOCK(inode->i_mode))
98147 goto put_fail;
98148 +
98149 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
98150 + err = -EACCES;
98151 + goto put_fail;
98152 + }
98153 +
98154 u = unix_find_socket_byinode(inode);
98155 if (!u)
98156 goto put_fail;
98157 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
98158 if (u) {
98159 struct dentry *dentry;
98160 dentry = unix_sk(u)->path.dentry;
98161 +
98162 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
98163 + err = -EPERM;
98164 + sock_put(u);
98165 + goto fail;
98166 + }
98167 +
98168 if (dentry)
98169 touch_atime(&unix_sk(u)->path);
98170 } else
98171 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
98172 */
98173 err = security_path_mknod(&path, dentry, mode, 0);
98174 if (!err) {
98175 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
98176 + err = -EACCES;
98177 + goto out;
98178 + }
98179 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
98180 if (!err) {
98181 res->mnt = mntget(path.mnt);
98182 res->dentry = dget(dentry);
98183 + gr_handle_create(dentry, path.mnt);
98184 }
98185 }
98186 +out:
98187 done_path_create(&path, dentry);
98188 return err;
98189 }
98190 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98191 seq_puts(seq, "Num RefCount Protocol Flags Type St "
98192 "Inode Path\n");
98193 else {
98194 - struct sock *s = v;
98195 + struct sock *s = v, *peer;
98196 struct unix_sock *u = unix_sk(s);
98197 unix_state_lock(s);
98198 + peer = unix_peer(s);
98199 + unix_state_unlock(s);
98200 +
98201 + unix_state_double_lock(s, peer);
98202
98203 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
98204 s,
98205 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98206 }
98207 for ( ; i < len; i++)
98208 seq_putc(seq, u->addr->name->sun_path[i]);
98209 - }
98210 - unix_state_unlock(s);
98211 + } else if (peer)
98212 + seq_printf(seq, " P%lu", sock_i_ino(peer));
98213 +
98214 + unix_state_double_unlock(s, peer);
98215 seq_putc(seq, '\n');
98216 }
98217
98218 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
98219 index 8800604..0526440 100644
98220 --- a/net/unix/sysctl_net_unix.c
98221 +++ b/net/unix/sysctl_net_unix.c
98222 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
98223
98224 int __net_init unix_sysctl_register(struct net *net)
98225 {
98226 - struct ctl_table *table;
98227 + ctl_table_no_const *table;
98228
98229 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
98230 if (table == NULL)
98231 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
98232 index 3f77f42..662d89b 100644
98233 --- a/net/vmw_vsock/af_vsock.c
98234 +++ b/net/vmw_vsock/af_vsock.c
98235 @@ -335,7 +335,7 @@ void vsock_for_each_connected_socket(void (*fn)(struct sock *sk))
98236 for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) {
98237 struct vsock_sock *vsk;
98238 list_for_each_entry(vsk, &vsock_connected_table[i],
98239 - connected_table);
98240 + connected_table)
98241 fn(sk_vsock(vsk));
98242 }
98243
98244 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
98245 index c8717c1..08539f5 100644
98246 --- a/net/wireless/wext-core.c
98247 +++ b/net/wireless/wext-core.c
98248 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98249 */
98250
98251 /* Support for very large requests */
98252 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
98253 - (user_length > descr->max_tokens)) {
98254 + if (user_length > descr->max_tokens) {
98255 /* Allow userspace to GET more than max so
98256 * we can support any size GET requests.
98257 * There is still a limit : -ENOMEM.
98258 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98259 }
98260 }
98261
98262 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
98263 - /*
98264 - * If this is a GET, but not NOMAX, it means that the extra
98265 - * data is not bounded by userspace, but by max_tokens. Thus
98266 - * set the length to max_tokens. This matches the extra data
98267 - * allocation.
98268 - * The driver should fill it with the number of tokens it
98269 - * provided, and it may check iwp->length rather than having
98270 - * knowledge of max_tokens. If the driver doesn't change the
98271 - * iwp->length, this ioctl just copies back max_token tokens
98272 - * filled with zeroes. Hopefully the driver isn't claiming
98273 - * them to be valid data.
98274 - */
98275 - iwp->length = descr->max_tokens;
98276 - }
98277 -
98278 err = handler(dev, info, (union iwreq_data *) iwp, extra);
98279
98280 iwp->length += essid_compat;
98281 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
98282 index ea970b8..c68edb9f 100644
98283 --- a/net/xfrm/xfrm_policy.c
98284 +++ b/net/xfrm/xfrm_policy.c
98285 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
98286 {
98287 policy->walk.dead = 1;
98288
98289 - atomic_inc(&policy->genid);
98290 + atomic_inc_unchecked(&policy->genid);
98291
98292 del_timer(&policy->polq.hold_timer);
98293 xfrm_queue_purge(&policy->polq.hold_queue);
98294 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
98295 hlist_add_head(&policy->bydst, chain);
98296 xfrm_pol_hold(policy);
98297 net->xfrm.policy_count[dir]++;
98298 - atomic_inc(&flow_cache_genid);
98299 + atomic_inc_unchecked(&flow_cache_genid);
98300 rt_genid_bump(net);
98301 if (delpol) {
98302 xfrm_policy_requeue(delpol, policy);
98303 @@ -1629,7 +1629,7 @@ free_dst:
98304 goto out;
98305 }
98306
98307 -static int inline
98308 +static inline int
98309 xfrm_dst_alloc_copy(void **target, const void *src, int size)
98310 {
98311 if (!*target) {
98312 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
98313 return 0;
98314 }
98315
98316 -static int inline
98317 +static inline int
98318 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98319 {
98320 #ifdef CONFIG_XFRM_SUB_POLICY
98321 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98322 #endif
98323 }
98324
98325 -static int inline
98326 +static inline int
98327 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
98328 {
98329 #ifdef CONFIG_XFRM_SUB_POLICY
98330 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
98331
98332 xdst->num_pols = num_pols;
98333 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
98334 - xdst->policy_genid = atomic_read(&pols[0]->genid);
98335 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
98336
98337 return xdst;
98338 }
98339 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
98340 if (xdst->xfrm_genid != dst->xfrm->genid)
98341 return 0;
98342 if (xdst->num_pols > 0 &&
98343 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
98344 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
98345 return 0;
98346
98347 mtu = dst_mtu(dst->child);
98348 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
98349 dst_ops->link_failure = xfrm_link_failure;
98350 if (likely(dst_ops->neigh_lookup == NULL))
98351 dst_ops->neigh_lookup = xfrm_neigh_lookup;
98352 - if (likely(afinfo->garbage_collect == NULL))
98353 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98354 + if (likely(afinfo->garbage_collect == NULL)) {
98355 + pax_open_kernel();
98356 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98357 + pax_close_kernel();
98358 + }
98359 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
98360 }
98361 spin_unlock(&xfrm_policy_afinfo_lock);
98362 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
98363 dst_ops->check = NULL;
98364 dst_ops->negative_advice = NULL;
98365 dst_ops->link_failure = NULL;
98366 - afinfo->garbage_collect = NULL;
98367 + pax_open_kernel();
98368 + *(void **)&afinfo->garbage_collect = NULL;
98369 + pax_close_kernel();
98370 }
98371 return err;
98372 }
98373 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
98374 sizeof(pol->xfrm_vec[i].saddr));
98375 pol->xfrm_vec[i].encap_family = mp->new_family;
98376 /* flush bundles */
98377 - atomic_inc(&pol->genid);
98378 + atomic_inc_unchecked(&pol->genid);
98379 }
98380 }
98381
98382 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
98383 index 78f66fa..b93d547 100644
98384 --- a/net/xfrm/xfrm_state.c
98385 +++ b/net/xfrm/xfrm_state.c
98386 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
98387
98388 if (unlikely(afinfo == NULL))
98389 return -EAFNOSUPPORT;
98390 - typemap = afinfo->type_map;
98391 + typemap = (const struct xfrm_type **)afinfo->type_map;
98392 spin_lock_bh(&xfrm_type_lock);
98393
98394 - if (likely(typemap[type->proto] == NULL))
98395 + if (likely(typemap[type->proto] == NULL)) {
98396 + pax_open_kernel();
98397 typemap[type->proto] = type;
98398 - else
98399 + pax_close_kernel();
98400 + } else
98401 err = -EEXIST;
98402 spin_unlock_bh(&xfrm_type_lock);
98403 xfrm_state_put_afinfo(afinfo);
98404 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
98405
98406 if (unlikely(afinfo == NULL))
98407 return -EAFNOSUPPORT;
98408 - typemap = afinfo->type_map;
98409 + typemap = (const struct xfrm_type **)afinfo->type_map;
98410 spin_lock_bh(&xfrm_type_lock);
98411
98412 if (unlikely(typemap[type->proto] != type))
98413 err = -ENOENT;
98414 - else
98415 + else {
98416 + pax_open_kernel();
98417 typemap[type->proto] = NULL;
98418 + pax_close_kernel();
98419 + }
98420 spin_unlock_bh(&xfrm_type_lock);
98421 xfrm_state_put_afinfo(afinfo);
98422 return err;
98423 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
98424 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
98425 {
98426 struct xfrm_state_afinfo *afinfo;
98427 - const struct xfrm_type **typemap;
98428 const struct xfrm_type *type;
98429 int modload_attempted = 0;
98430
98431 @@ -222,9 +226,8 @@ retry:
98432 afinfo = xfrm_state_get_afinfo(family);
98433 if (unlikely(afinfo == NULL))
98434 return NULL;
98435 - typemap = afinfo->type_map;
98436
98437 - type = typemap[proto];
98438 + type = afinfo->type_map[proto];
98439 if (unlikely(type && !try_module_get(type->owner)))
98440 type = NULL;
98441 if (!type && !modload_attempted) {
98442 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98443 return -EAFNOSUPPORT;
98444
98445 err = -EEXIST;
98446 - modemap = afinfo->mode_map;
98447 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98448 spin_lock_bh(&xfrm_mode_lock);
98449 if (modemap[mode->encap])
98450 goto out;
98451 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98452 if (!try_module_get(afinfo->owner))
98453 goto out;
98454
98455 - mode->afinfo = afinfo;
98456 + pax_open_kernel();
98457 + *(const void **)&mode->afinfo = afinfo;
98458 modemap[mode->encap] = mode;
98459 + pax_close_kernel();
98460 err = 0;
98461
98462 out:
98463 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
98464 return -EAFNOSUPPORT;
98465
98466 err = -ENOENT;
98467 - modemap = afinfo->mode_map;
98468 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98469 spin_lock_bh(&xfrm_mode_lock);
98470 if (likely(modemap[mode->encap] == mode)) {
98471 + pax_open_kernel();
98472 modemap[mode->encap] = NULL;
98473 + pax_close_kernel();
98474 module_put(mode->afinfo->owner);
98475 err = 0;
98476 }
98477 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
98478 u32 xfrm_get_acqseq(void)
98479 {
98480 u32 res;
98481 - static atomic_t acqseq;
98482 + static atomic_unchecked_t acqseq;
98483
98484 do {
98485 - res = atomic_inc_return(&acqseq);
98486 + res = atomic_inc_return_unchecked(&acqseq);
98487 } while (!res);
98488
98489 return res;
98490 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
98491 index 05a6e3d..6716ec9 100644
98492 --- a/net/xfrm/xfrm_sysctl.c
98493 +++ b/net/xfrm/xfrm_sysctl.c
98494 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
98495
98496 int __net_init xfrm_sysctl_init(struct net *net)
98497 {
98498 - struct ctl_table *table;
98499 + ctl_table_no_const *table;
98500
98501 __xfrm_sysctl_init(net);
98502
98503 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
98504 index d5d859c..781cbcb 100644
98505 --- a/scripts/Makefile.build
98506 +++ b/scripts/Makefile.build
98507 @@ -111,7 +111,7 @@ endif
98508 endif
98509
98510 # Do not include host rules unless needed
98511 -ifneq ($(hostprogs-y)$(hostprogs-m),)
98512 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
98513 include scripts/Makefile.host
98514 endif
98515
98516 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
98517 index 686cb0d..9d653bf 100644
98518 --- a/scripts/Makefile.clean
98519 +++ b/scripts/Makefile.clean
98520 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
98521 __clean-files := $(extra-y) $(always) \
98522 $(targets) $(clean-files) \
98523 $(host-progs) \
98524 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
98525 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
98526 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
98527
98528 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
98529
98530 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
98531 index 1ac414f..38575f7 100644
98532 --- a/scripts/Makefile.host
98533 +++ b/scripts/Makefile.host
98534 @@ -31,6 +31,8 @@
98535 # Note: Shared libraries consisting of C++ files are not supported
98536
98537 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
98538 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
98539 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
98540
98541 # C code
98542 # Executables compiled from a single .c file
98543 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
98544 # Shared libaries (only .c supported)
98545 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
98546 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
98547 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
98548 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
98549 # Remove .so files from "xxx-objs"
98550 host-cobjs := $(filter-out %.so,$(host-cobjs))
98551 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
98552
98553 -#Object (.o) files used by the shared libaries
98554 +# Object (.o) files used by the shared libaries
98555 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
98556 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
98557
98558 # output directory for programs/.o files
98559 # hostprogs-y := tools/build may have been specified. Retrieve directory
98560 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
98561 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
98562 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
98563 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
98564 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
98565 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
98566 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
98567 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
98568
98569 obj-dirs += $(host-objdirs)
98570 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
98571 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
98572 $(call if_changed_dep,host-cshobjs)
98573
98574 +# Compile .c file, create position independent .o file
98575 +# host-cxxshobjs -> .o
98576 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
98577 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
98578 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
98579 + $(call if_changed_dep,host-cxxshobjs)
98580 +
98581 # Link a shared library, based on position independent .o files
98582 # *.o -> .so shared library (host-cshlib)
98583 quiet_cmd_host-cshlib = HOSTLLD -shared $@
98584 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
98585 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
98586 $(call if_changed,host-cshlib)
98587
98588 +# Link a shared library, based on position independent .o files
98589 +# *.o -> .so shared library (host-cxxshlib)
98590 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
98591 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
98592 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
98593 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
98594 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
98595 + $(call if_changed,host-cxxshlib)
98596 +
98597 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
98598 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
98599 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
98600
98601 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
98602 index 078fe1d..fbdb363 100644
98603 --- a/scripts/basic/fixdep.c
98604 +++ b/scripts/basic/fixdep.c
98605 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
98606 /*
98607 * Lookup a value in the configuration string.
98608 */
98609 -static int is_defined_config(const char *name, int len, unsigned int hash)
98610 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
98611 {
98612 struct item *aux;
98613
98614 @@ -211,10 +211,10 @@ static void clear_config(void)
98615 /*
98616 * Record the use of a CONFIG_* word.
98617 */
98618 -static void use_config(const char *m, int slen)
98619 +static void use_config(const char *m, unsigned int slen)
98620 {
98621 unsigned int hash = strhash(m, slen);
98622 - int c, i;
98623 + unsigned int c, i;
98624
98625 if (is_defined_config(m, slen, hash))
98626 return;
98627 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
98628
98629 static void parse_config_file(const char *map, size_t len)
98630 {
98631 - const int *end = (const int *) (map + len);
98632 + const unsigned int *end = (const unsigned int *) (map + len);
98633 /* start at +1, so that p can never be < map */
98634 - const int *m = (const int *) map + 1;
98635 + const unsigned int *m = (const unsigned int *) map + 1;
98636 const char *p, *q;
98637
98638 for (; m < end; m++) {
98639 @@ -435,7 +435,7 @@ static void print_deps(void)
98640 static void traps(void)
98641 {
98642 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
98643 - int *p = (int *)test;
98644 + unsigned int *p = (unsigned int *)test;
98645
98646 if (*p != INT_CONF) {
98647 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
98648 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
98649 new file mode 100644
98650 index 0000000..5e0222d
98651 --- /dev/null
98652 +++ b/scripts/gcc-plugin.sh
98653 @@ -0,0 +1,17 @@
98654 +#!/bin/bash
98655 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
98656 +#include "gcc-plugin.h"
98657 +#include "tree.h"
98658 +#include "tm.h"
98659 +#include "rtl.h"
98660 +#ifdef ENABLE_BUILD_WITH_CXX
98661 +#warning $2
98662 +#else
98663 +#warning $1
98664 +#endif
98665 +EOF`
98666 +if [ $? -eq 0 ]
98667 +then
98668 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98669 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98670 +fi
98671 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98672 index 643764f..6cc0137 100644
98673 --- a/scripts/headers_install.sh
98674 +++ b/scripts/headers_install.sh
98675 @@ -29,6 +29,7 @@ do
98676 FILE="$(basename "$i")"
98677 sed -r \
98678 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98679 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98680 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98681 -e 's@^#include <linux/compiler.h>@@' \
98682 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
98683 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
98684 index 0149949..d482a0d 100644
98685 --- a/scripts/link-vmlinux.sh
98686 +++ b/scripts/link-vmlinux.sh
98687 @@ -158,7 +158,7 @@ else
98688 fi;
98689
98690 # final build of init/
98691 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98692 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98693
98694 kallsymso=""
98695 kallsyms_vmlinux=""
98696 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98697 index 45f9a33..e4194b3 100644
98698 --- a/scripts/mod/file2alias.c
98699 +++ b/scripts/mod/file2alias.c
98700 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
98701 unsigned long size, unsigned long id_size,
98702 void *symval)
98703 {
98704 - int i;
98705 + unsigned int i;
98706
98707 if (size % id_size || size < id_size) {
98708 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98709 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
98710 /* USB is special because the bcdDevice can be matched against a numeric range */
98711 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98712 static void do_usb_entry(void *symval,
98713 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98714 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98715 unsigned char range_lo, unsigned char range_hi,
98716 unsigned char max, struct module *mod)
98717 {
98718 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98719 {
98720 unsigned int devlo, devhi;
98721 unsigned char chi, clo, max;
98722 - int ndigits;
98723 + unsigned int ndigits;
98724
98725 DEF_FIELD(symval, usb_device_id, match_flags);
98726 DEF_FIELD(symval, usb_device_id, idVendor);
98727 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98728 for (i = 0; i < count; i++) {
98729 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98730 char acpi_id[sizeof(*id)];
98731 - int j;
98732 + unsigned int j;
98733
98734 buf_printf(&mod->dev_table_buf,
98735 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98736 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98737
98738 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98739 const char *id = (char *)(*devs)[j].id;
98740 - int i2, j2;
98741 + unsigned int i2, j2;
98742 int dup = 0;
98743
98744 if (!id[0])
98745 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98746 /* add an individual alias for every device entry */
98747 if (!dup) {
98748 char acpi_id[PNP_ID_LEN];
98749 - int k;
98750 + unsigned int k;
98751
98752 buf_printf(&mod->dev_table_buf,
98753 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
98754 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
98755 static int do_dmi_entry(const char *filename, void *symval,
98756 char *alias)
98757 {
98758 - int i, j;
98759 + unsigned int i, j;
98760 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
98761 sprintf(alias, "dmi*");
98762
98763 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
98764 index a4be8e1..6e8a5fb 100644
98765 --- a/scripts/mod/modpost.c
98766 +++ b/scripts/mod/modpost.c
98767 @@ -933,6 +933,7 @@ enum mismatch {
98768 ANY_INIT_TO_ANY_EXIT,
98769 ANY_EXIT_TO_ANY_INIT,
98770 EXPORT_TO_INIT_EXIT,
98771 + DATA_TO_TEXT
98772 };
98773
98774 struct sectioncheck {
98775 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
98776 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
98777 .mismatch = EXPORT_TO_INIT_EXIT,
98778 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
98779 +},
98780 +/* Do not reference code from writable data */
98781 +{
98782 + .fromsec = { DATA_SECTIONS, NULL },
98783 + .tosec = { TEXT_SECTIONS, NULL },
98784 + .mismatch = DATA_TO_TEXT
98785 }
98786 };
98787
98788 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
98789 continue;
98790 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
98791 continue;
98792 - if (sym->st_value == addr)
98793 - return sym;
98794 /* Find a symbol nearby - addr are maybe negative */
98795 d = sym->st_value - addr;
98796 + if (d == 0)
98797 + return sym;
98798 if (d < 0)
98799 d = addr - sym->st_value;
98800 if (d < distance) {
98801 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
98802 tosym, prl_to, prl_to, tosym);
98803 free(prl_to);
98804 break;
98805 + case DATA_TO_TEXT:
98806 +#if 0
98807 + fprintf(stderr,
98808 + "The %s %s:%s references\n"
98809 + "the %s %s:%s%s\n",
98810 + from, fromsec, fromsym, to, tosec, tosym, to_p);
98811 +#endif
98812 + break;
98813 }
98814 fprintf(stderr, "\n");
98815 }
98816 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
98817 static void check_sec_ref(struct module *mod, const char *modname,
98818 struct elf_info *elf)
98819 {
98820 - int i;
98821 + unsigned int i;
98822 Elf_Shdr *sechdrs = elf->sechdrs;
98823
98824 /* Walk through all sections */
98825 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
98826 va_end(ap);
98827 }
98828
98829 -void buf_write(struct buffer *buf, const char *s, int len)
98830 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
98831 {
98832 if (buf->size - buf->pos < len) {
98833 buf->size += len + SZ;
98834 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98835 if (fstat(fileno(file), &st) < 0)
98836 goto close_write;
98837
98838 - if (st.st_size != b->pos)
98839 + if (st.st_size != (off_t)b->pos)
98840 goto close_write;
98841
98842 tmp = NOFAIL(malloc(b->pos));
98843 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98844 index 51207e4..f7d603d 100644
98845 --- a/scripts/mod/modpost.h
98846 +++ b/scripts/mod/modpost.h
98847 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98848
98849 struct buffer {
98850 char *p;
98851 - int pos;
98852 - int size;
98853 + unsigned int pos;
98854 + unsigned int size;
98855 };
98856
98857 void __attribute__((format(printf, 2, 3)))
98858 buf_printf(struct buffer *buf, const char *fmt, ...);
98859
98860 void
98861 -buf_write(struct buffer *buf, const char *s, int len);
98862 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98863
98864 struct module {
98865 struct module *next;
98866 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98867 index 9dfcd6d..099068e 100644
98868 --- a/scripts/mod/sumversion.c
98869 +++ b/scripts/mod/sumversion.c
98870 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98871 goto out;
98872 }
98873
98874 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98875 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98876 warn("writing sum in %s failed: %s\n",
98877 filename, strerror(errno));
98878 goto out;
98879 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98880 index acb8650..b8c5f02 100644
98881 --- a/scripts/package/builddeb
98882 +++ b/scripts/package/builddeb
98883 @@ -246,6 +246,7 @@ fi
98884 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98885 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98886 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98887 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98888 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98889 mkdir -p "$destdir"
98890 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98891 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98892 index 68bb4ef..2f419e1 100644
98893 --- a/scripts/pnmtologo.c
98894 +++ b/scripts/pnmtologo.c
98895 @@ -244,14 +244,14 @@ static void write_header(void)
98896 fprintf(out, " * Linux logo %s\n", logoname);
98897 fputs(" */\n\n", out);
98898 fputs("#include <linux/linux_logo.h>\n\n", out);
98899 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98900 + fprintf(out, "static unsigned char %s_data[] = {\n",
98901 logoname);
98902 }
98903
98904 static void write_footer(void)
98905 {
98906 fputs("\n};\n\n", out);
98907 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98908 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98909 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98910 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98911 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98912 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98913 fputs("\n};\n\n", out);
98914
98915 /* write logo clut */
98916 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98917 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98918 logoname);
98919 write_hex_cnt = 0;
98920 for (i = 0; i < logo_clutsize; i++) {
98921 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98922 index f5eb43d..1814de8 100644
98923 --- a/scripts/sortextable.h
98924 +++ b/scripts/sortextable.h
98925 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98926 const char *secstrtab;
98927 const char *strtab;
98928 char *extab_image;
98929 - int extab_index = 0;
98930 - int i;
98931 - int idx;
98932 + unsigned int extab_index = 0;
98933 + unsigned int i;
98934 + unsigned int idx;
98935
98936 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98937 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98938 diff --git a/security/Kconfig b/security/Kconfig
98939 index e9c6ac7..c5d45c8 100644
98940 --- a/security/Kconfig
98941 +++ b/security/Kconfig
98942 @@ -4,6 +4,959 @@
98943
98944 menu "Security options"
98945
98946 +menu "Grsecurity"
98947 +
98948 + config ARCH_TRACK_EXEC_LIMIT
98949 + bool
98950 +
98951 + config PAX_KERNEXEC_PLUGIN
98952 + bool
98953 +
98954 + config PAX_PER_CPU_PGD
98955 + bool
98956 +
98957 + config TASK_SIZE_MAX_SHIFT
98958 + int
98959 + depends on X86_64
98960 + default 47 if !PAX_PER_CPU_PGD
98961 + default 42 if PAX_PER_CPU_PGD
98962 +
98963 + config PAX_ENABLE_PAE
98964 + bool
98965 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98966 +
98967 + config PAX_USERCOPY_SLABS
98968 + bool
98969 +
98970 +config GRKERNSEC
98971 + bool "Grsecurity"
98972 + select CRYPTO
98973 + select CRYPTO_SHA256
98974 + select PROC_FS
98975 + select STOP_MACHINE
98976 + select TTY
98977 + help
98978 + If you say Y here, you will be able to configure many features
98979 + that will enhance the security of your system. It is highly
98980 + recommended that you say Y here and read through the help
98981 + for each option so that you fully understand the features and
98982 + can evaluate their usefulness for your machine.
98983 +
98984 +choice
98985 + prompt "Configuration Method"
98986 + depends on GRKERNSEC
98987 + default GRKERNSEC_CONFIG_CUSTOM
98988 + help
98989 +
98990 +config GRKERNSEC_CONFIG_AUTO
98991 + bool "Automatic"
98992 + help
98993 + If you choose this configuration method, you'll be able to answer a small
98994 + number of simple questions about how you plan to use this kernel.
98995 + The settings of grsecurity and PaX will be automatically configured for
98996 + the highest commonly-used settings within the provided constraints.
98997 +
98998 + If you require additional configuration, custom changes can still be made
98999 + from the "custom configuration" menu.
99000 +
99001 +config GRKERNSEC_CONFIG_CUSTOM
99002 + bool "Custom"
99003 + help
99004 + If you choose this configuration method, you'll be able to configure all
99005 + grsecurity and PaX settings manually. Via this method, no options are
99006 + automatically enabled.
99007 +
99008 +endchoice
99009 +
99010 +choice
99011 + prompt "Usage Type"
99012 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99013 + default GRKERNSEC_CONFIG_SERVER
99014 + help
99015 +
99016 +config GRKERNSEC_CONFIG_SERVER
99017 + bool "Server"
99018 + help
99019 + Choose this option if you plan to use this kernel on a server.
99020 +
99021 +config GRKERNSEC_CONFIG_DESKTOP
99022 + bool "Desktop"
99023 + help
99024 + Choose this option if you plan to use this kernel on a desktop.
99025 +
99026 +endchoice
99027 +
99028 +choice
99029 + prompt "Virtualization Type"
99030 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
99031 + default GRKERNSEC_CONFIG_VIRT_NONE
99032 + help
99033 +
99034 +config GRKERNSEC_CONFIG_VIRT_NONE
99035 + bool "None"
99036 + help
99037 + Choose this option if this kernel will be run on bare metal.
99038 +
99039 +config GRKERNSEC_CONFIG_VIRT_GUEST
99040 + bool "Guest"
99041 + help
99042 + Choose this option if this kernel will be run as a VM guest.
99043 +
99044 +config GRKERNSEC_CONFIG_VIRT_HOST
99045 + bool "Host"
99046 + help
99047 + Choose this option if this kernel will be run as a VM host.
99048 +
99049 +endchoice
99050 +
99051 +choice
99052 + prompt "Virtualization Hardware"
99053 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99054 + help
99055 +
99056 +config GRKERNSEC_CONFIG_VIRT_EPT
99057 + bool "EPT/RVI Processor Support"
99058 + depends on X86
99059 + help
99060 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
99061 + hardware virtualization. This allows for additional kernel hardening protections
99062 + to operate without additional performance impact.
99063 +
99064 + To see if your Intel processor supports EPT, see:
99065 + http://ark.intel.com/Products/VirtualizationTechnology
99066 + (Most Core i3/5/7 support EPT)
99067 +
99068 + To see if your AMD processor supports RVI, see:
99069 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
99070 +
99071 +config GRKERNSEC_CONFIG_VIRT_SOFT
99072 + bool "First-gen/No Hardware Virtualization"
99073 + help
99074 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
99075 + support hardware virtualization or doesn't support the EPT/RVI extensions.
99076 +
99077 +endchoice
99078 +
99079 +choice
99080 + prompt "Virtualization Software"
99081 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99082 + help
99083 +
99084 +config GRKERNSEC_CONFIG_VIRT_XEN
99085 + bool "Xen"
99086 + help
99087 + Choose this option if this kernel is running as a Xen guest or host.
99088 +
99089 +config GRKERNSEC_CONFIG_VIRT_VMWARE
99090 + bool "VMWare"
99091 + help
99092 + Choose this option if this kernel is running as a VMWare guest or host.
99093 +
99094 +config GRKERNSEC_CONFIG_VIRT_KVM
99095 + bool "KVM"
99096 + help
99097 + Choose this option if this kernel is running as a KVM guest or host.
99098 +
99099 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
99100 + bool "VirtualBox"
99101 + help
99102 + Choose this option if this kernel is running as a VirtualBox guest or host.
99103 +
99104 +endchoice
99105 +
99106 +choice
99107 + prompt "Required Priorities"
99108 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99109 + default GRKERNSEC_CONFIG_PRIORITY_PERF
99110 + help
99111 +
99112 +config GRKERNSEC_CONFIG_PRIORITY_PERF
99113 + bool "Performance"
99114 + help
99115 + Choose this option if performance is of highest priority for this deployment
99116 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
99117 + clearing of structures intended for userland, and freed memory sanitizing will
99118 + be disabled.
99119 +
99120 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
99121 + bool "Security"
99122 + help
99123 + Choose this option if security is of highest priority for this deployment of
99124 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
99125 + for userland, and freed memory sanitizing will be enabled for this kernel.
99126 + In a worst-case scenario, these features can introduce a 20% performance hit
99127 + (UDEREF on x64 contributing half of this hit).
99128 +
99129 +endchoice
99130 +
99131 +menu "Default Special Groups"
99132 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99133 +
99134 +config GRKERNSEC_PROC_GID
99135 + int "GID exempted from /proc restrictions"
99136 + default 1001
99137 + help
99138 + Setting this GID determines which group will be exempted from
99139 + grsecurity's /proc restrictions, allowing users of the specified
99140 + group to view network statistics and the existence of other users'
99141 + processes on the system. This GID may also be chosen at boot time
99142 + via "grsec_proc_gid=" on the kernel commandline.
99143 +
99144 +config GRKERNSEC_TPE_UNTRUSTED_GID
99145 + int "GID for TPE-untrusted users"
99146 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
99147 + default 1005
99148 + help
99149 + Setting this GID determines which group untrusted users should
99150 + be added to. These users will be placed under grsecurity's Trusted Path
99151 + Execution mechanism, preventing them from executing their own binaries.
99152 + The users will only be able to execute binaries in directories owned and
99153 + writable only by the root user. If the sysctl option is enabled, a sysctl
99154 + option with name "tpe_gid" is created.
99155 +
99156 +config GRKERNSEC_TPE_TRUSTED_GID
99157 + int "GID for TPE-trusted users"
99158 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
99159 + default 1005
99160 + help
99161 + Setting this GID determines what group TPE restrictions will be
99162 + *disabled* for. If the sysctl option is enabled, a sysctl option
99163 + with name "tpe_gid" is created.
99164 +
99165 +config GRKERNSEC_SYMLINKOWN_GID
99166 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
99167 + depends on GRKERNSEC_CONFIG_SERVER
99168 + default 1006
99169 + help
99170 + Setting this GID determines what group kernel-enforced
99171 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
99172 + is enabled, a sysctl option with name "symlinkown_gid" is created.
99173 +
99174 +
99175 +endmenu
99176 +
99177 +menu "Customize Configuration"
99178 +depends on GRKERNSEC
99179 +
99180 +menu "PaX"
99181 +
99182 +config PAX
99183 + bool "Enable various PaX features"
99184 + default y if GRKERNSEC_CONFIG_AUTO
99185 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
99186 + help
99187 + This allows you to enable various PaX features. PaX adds
99188 + intrusion prevention mechanisms to the kernel that reduce
99189 + the risks posed by exploitable memory corruption bugs.
99190 +
99191 +menu "PaX Control"
99192 + depends on PAX
99193 +
99194 +config PAX_SOFTMODE
99195 + bool 'Support soft mode'
99196 + help
99197 + Enabling this option will allow you to run PaX in soft mode, that
99198 + is, PaX features will not be enforced by default, only on executables
99199 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
99200 + support as they are the only way to mark executables for soft mode use.
99201 +
99202 + Soft mode can be activated by using the "pax_softmode=1" kernel command
99203 + line option on boot. Furthermore you can control various PaX features
99204 + at runtime via the entries in /proc/sys/kernel/pax.
99205 +
99206 +config PAX_EI_PAX
99207 + bool 'Use legacy ELF header marking'
99208 + default y if GRKERNSEC_CONFIG_AUTO
99209 + help
99210 + Enabling this option will allow you to control PaX features on
99211 + a per executable basis via the 'chpax' utility available at
99212 + http://pax.grsecurity.net/. The control flags will be read from
99213 + an otherwise reserved part of the ELF header. This marking has
99214 + numerous drawbacks (no support for soft-mode, toolchain does not
99215 + know about the non-standard use of the ELF header) therefore it
99216 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
99217 + support.
99218 +
99219 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
99220 + support as well, they will override the legacy EI_PAX marks.
99221 +
99222 + If you enable none of the marking options then all applications
99223 + will run with PaX enabled on them by default.
99224 +
99225 +config PAX_PT_PAX_FLAGS
99226 + bool 'Use ELF program header marking'
99227 + default y if GRKERNSEC_CONFIG_AUTO
99228 + help
99229 + Enabling this option will allow you to control PaX features on
99230 + a per executable basis via the 'paxctl' utility available at
99231 + http://pax.grsecurity.net/. The control flags will be read from
99232 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
99233 + has the benefits of supporting both soft mode and being fully
99234 + integrated into the toolchain (the binutils patch is available
99235 + from http://pax.grsecurity.net).
99236 +
99237 + Note that if you enable the legacy EI_PAX marking support as well,
99238 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
99239 +
99240 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99241 + must make sure that the marks are the same if a binary has both marks.
99242 +
99243 + If you enable none of the marking options then all applications
99244 + will run with PaX enabled on them by default.
99245 +
99246 +config PAX_XATTR_PAX_FLAGS
99247 + bool 'Use filesystem extended attributes marking'
99248 + default y if GRKERNSEC_CONFIG_AUTO
99249 + select CIFS_XATTR if CIFS
99250 + select EXT2_FS_XATTR if EXT2_FS
99251 + select EXT3_FS_XATTR if EXT3_FS
99252 + select EXT4_FS_XATTR if EXT4_FS
99253 + select JFFS2_FS_XATTR if JFFS2_FS
99254 + select REISERFS_FS_XATTR if REISERFS_FS
99255 + select SQUASHFS_XATTR if SQUASHFS
99256 + select TMPFS_XATTR if TMPFS
99257 + select UBIFS_FS_XATTR if UBIFS_FS
99258 + help
99259 + Enabling this option will allow you to control PaX features on
99260 + a per executable basis via the 'setfattr' utility. The control
99261 + flags will be read from the user.pax.flags extended attribute of
99262 + the file. This marking has the benefit of supporting binary-only
99263 + applications that self-check themselves (e.g., skype) and would
99264 + not tolerate chpax/paxctl changes. The main drawback is that
99265 + extended attributes are not supported by some filesystems (e.g.,
99266 + isofs, udf, vfat) so copying files through such filesystems will
99267 + lose the extended attributes and these PaX markings.
99268 +
99269 + Note that if you enable the legacy EI_PAX marking support as well,
99270 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
99271 +
99272 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99273 + must make sure that the marks are the same if a binary has both marks.
99274 +
99275 + If you enable none of the marking options then all applications
99276 + will run with PaX enabled on them by default.
99277 +
99278 +choice
99279 + prompt 'MAC system integration'
99280 + default PAX_HAVE_ACL_FLAGS
99281 + help
99282 + Mandatory Access Control systems have the option of controlling
99283 + PaX flags on a per executable basis, choose the method supported
99284 + by your particular system.
99285 +
99286 + - "none": if your MAC system does not interact with PaX,
99287 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
99288 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
99289 +
99290 + NOTE: this option is for developers/integrators only.
99291 +
99292 + config PAX_NO_ACL_FLAGS
99293 + bool 'none'
99294 +
99295 + config PAX_HAVE_ACL_FLAGS
99296 + bool 'direct'
99297 +
99298 + config PAX_HOOK_ACL_FLAGS
99299 + bool 'hook'
99300 +endchoice
99301 +
99302 +endmenu
99303 +
99304 +menu "Non-executable pages"
99305 + depends on PAX
99306 +
99307 +config PAX_NOEXEC
99308 + bool "Enforce non-executable pages"
99309 + default y if GRKERNSEC_CONFIG_AUTO
99310 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
99311 + help
99312 + By design some architectures do not allow for protecting memory
99313 + pages against execution or even if they do, Linux does not make
99314 + use of this feature. In practice this means that if a page is
99315 + readable (such as the stack or heap) it is also executable.
99316 +
99317 + There is a well known exploit technique that makes use of this
99318 + fact and a common programming mistake where an attacker can
99319 + introduce code of his choice somewhere in the attacked program's
99320 + memory (typically the stack or the heap) and then execute it.
99321 +
99322 + If the attacked program was running with different (typically
99323 + higher) privileges than that of the attacker, then he can elevate
99324 + his own privilege level (e.g. get a root shell, write to files for
99325 + which he does not have write access to, etc).
99326 +
99327 + Enabling this option will let you choose from various features
99328 + that prevent the injection and execution of 'foreign' code in
99329 + a program.
99330 +
99331 + This will also break programs that rely on the old behaviour and
99332 + expect that dynamically allocated memory via the malloc() family
99333 + of functions is executable (which it is not). Notable examples
99334 + are the XFree86 4.x server, the java runtime and wine.
99335 +
99336 +config PAX_PAGEEXEC
99337 + bool "Paging based non-executable pages"
99338 + default y if GRKERNSEC_CONFIG_AUTO
99339 + 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)
99340 + select ARCH_TRACK_EXEC_LIMIT if X86_32
99341 + help
99342 + This implementation is based on the paging feature of the CPU.
99343 + On i386 without hardware non-executable bit support there is a
99344 + variable but usually low performance impact, however on Intel's
99345 + P4 core based CPUs it is very high so you should not enable this
99346 + for kernels meant to be used on such CPUs.
99347 +
99348 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
99349 + with hardware non-executable bit support there is no performance
99350 + impact, on ppc the impact is negligible.
99351 +
99352 + Note that several architectures require various emulations due to
99353 + badly designed userland ABIs, this will cause a performance impact
99354 + but will disappear as soon as userland is fixed. For example, ppc
99355 + userland MUST have been built with secure-plt by a recent toolchain.
99356 +
99357 +config PAX_SEGMEXEC
99358 + bool "Segmentation based non-executable pages"
99359 + default y if GRKERNSEC_CONFIG_AUTO
99360 + depends on PAX_NOEXEC && X86_32
99361 + help
99362 + This implementation is based on the segmentation feature of the
99363 + CPU and has a very small performance impact, however applications
99364 + will be limited to a 1.5 GB address space instead of the normal
99365 + 3 GB.
99366 +
99367 +config PAX_EMUTRAMP
99368 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
99369 + default y if PARISC
99370 + help
99371 + There are some programs and libraries that for one reason or
99372 + another attempt to execute special small code snippets from
99373 + non-executable memory pages. Most notable examples are the
99374 + signal handler return code generated by the kernel itself and
99375 + the GCC trampolines.
99376 +
99377 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
99378 + such programs will no longer work under your kernel.
99379 +
99380 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
99381 + utilities to enable trampoline emulation for the affected programs
99382 + yet still have the protection provided by the non-executable pages.
99383 +
99384 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
99385 + your system will not even boot.
99386 +
99387 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
99388 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
99389 + for the affected files.
99390 +
99391 + NOTE: enabling this feature *may* open up a loophole in the
99392 + protection provided by non-executable pages that an attacker
99393 + could abuse. Therefore the best solution is to not have any
99394 + files on your system that would require this option. This can
99395 + be achieved by not using libc5 (which relies on the kernel
99396 + signal handler return code) and not using or rewriting programs
99397 + that make use of the nested function implementation of GCC.
99398 + Skilled users can just fix GCC itself so that it implements
99399 + nested function calls in a way that does not interfere with PaX.
99400 +
99401 +config PAX_EMUSIGRT
99402 + bool "Automatically emulate sigreturn trampolines"
99403 + depends on PAX_EMUTRAMP && PARISC
99404 + default y
99405 + help
99406 + Enabling this option will have the kernel automatically detect
99407 + and emulate signal return trampolines executing on the stack
99408 + that would otherwise lead to task termination.
99409 +
99410 + This solution is intended as a temporary one for users with
99411 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
99412 + Modula-3 runtime, etc) or executables linked to such, basically
99413 + everything that does not specify its own SA_RESTORER function in
99414 + normal executable memory like glibc 2.1+ does.
99415 +
99416 + On parisc you MUST enable this option, otherwise your system will
99417 + not even boot.
99418 +
99419 + NOTE: this feature cannot be disabled on a per executable basis
99420 + and since it *does* open up a loophole in the protection provided
99421 + by non-executable pages, the best solution is to not have any
99422 + files on your system that would require this option.
99423 +
99424 +config PAX_MPROTECT
99425 + bool "Restrict mprotect()"
99426 + default y if GRKERNSEC_CONFIG_AUTO
99427 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
99428 + help
99429 + Enabling this option will prevent programs from
99430 + - changing the executable status of memory pages that were
99431 + not originally created as executable,
99432 + - making read-only executable pages writable again,
99433 + - creating executable pages from anonymous memory,
99434 + - making read-only-after-relocations (RELRO) data pages writable again.
99435 +
99436 + You should say Y here to complete the protection provided by
99437 + the enforcement of non-executable pages.
99438 +
99439 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99440 + this feature on a per file basis.
99441 +
99442 +config PAX_MPROTECT_COMPAT
99443 + bool "Use legacy/compat protection demoting (read help)"
99444 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99445 + depends on PAX_MPROTECT
99446 + help
99447 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
99448 + by sending the proper error code to the application. For some broken
99449 + userland, this can cause problems with Python or other applications. The
99450 + current implementation however allows for applications like clamav to
99451 + detect if JIT compilation/execution is allowed and to fall back gracefully
99452 + to an interpreter-based mode if it does not. While we encourage everyone
99453 + to use the current implementation as-is and push upstream to fix broken
99454 + userland (note that the RWX logging option can assist with this), in some
99455 + environments this may not be possible. Having to disable MPROTECT
99456 + completely on certain binaries reduces the security benefit of PaX,
99457 + so this option is provided for those environments to revert to the old
99458 + behavior.
99459 +
99460 +config PAX_ELFRELOCS
99461 + bool "Allow ELF text relocations (read help)"
99462 + depends on PAX_MPROTECT
99463 + default n
99464 + help
99465 + Non-executable pages and mprotect() restrictions are effective
99466 + in preventing the introduction of new executable code into an
99467 + attacked task's address space. There remain only two venues
99468 + for this kind of attack: if the attacker can execute already
99469 + existing code in the attacked task then he can either have it
99470 + create and mmap() a file containing his code or have it mmap()
99471 + an already existing ELF library that does not have position
99472 + independent code in it and use mprotect() on it to make it
99473 + writable and copy his code there. While protecting against
99474 + the former approach is beyond PaX, the latter can be prevented
99475 + by having only PIC ELF libraries on one's system (which do not
99476 + need to relocate their code). If you are sure this is your case,
99477 + as is the case with all modern Linux distributions, then leave
99478 + this option disabled. You should say 'n' here.
99479 +
99480 +config PAX_ETEXECRELOCS
99481 + bool "Allow ELF ET_EXEC text relocations"
99482 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
99483 + select PAX_ELFRELOCS
99484 + default y
99485 + help
99486 + On some architectures there are incorrectly created applications
99487 + that require text relocations and would not work without enabling
99488 + this option. If you are an alpha, ia64 or parisc user, you should
99489 + enable this option and disable it once you have made sure that
99490 + none of your applications need it.
99491 +
99492 +config PAX_EMUPLT
99493 + bool "Automatically emulate ELF PLT"
99494 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
99495 + default y
99496 + help
99497 + Enabling this option will have the kernel automatically detect
99498 + and emulate the Procedure Linkage Table entries in ELF files.
99499 + On some architectures such entries are in writable memory, and
99500 + become non-executable leading to task termination. Therefore
99501 + it is mandatory that you enable this option on alpha, parisc,
99502 + sparc and sparc64, otherwise your system would not even boot.
99503 +
99504 + NOTE: this feature *does* open up a loophole in the protection
99505 + provided by the non-executable pages, therefore the proper
99506 + solution is to modify the toolchain to produce a PLT that does
99507 + not need to be writable.
99508 +
99509 +config PAX_DLRESOLVE
99510 + bool 'Emulate old glibc resolver stub'
99511 + depends on PAX_EMUPLT && SPARC
99512 + default n
99513 + help
99514 + This option is needed if userland has an old glibc (before 2.4)
99515 + that puts a 'save' instruction into the runtime generated resolver
99516 + stub that needs special emulation.
99517 +
99518 +config PAX_KERNEXEC
99519 + bool "Enforce non-executable kernel pages"
99520 + 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))
99521 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
99522 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
99523 + select PAX_KERNEXEC_PLUGIN if X86_64
99524 + help
99525 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
99526 + that is, enabling this option will make it harder to inject
99527 + and execute 'foreign' code in kernel memory itself.
99528 +
99529 +choice
99530 + prompt "Return Address Instrumentation Method"
99531 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
99532 + depends on PAX_KERNEXEC_PLUGIN
99533 + help
99534 + Select the method used to instrument function pointer dereferences.
99535 + Note that binary modules cannot be instrumented by this approach.
99536 +
99537 + Note that the implementation requires a gcc with plugin support,
99538 + i.e., gcc 4.5 or newer. You may need to install the supporting
99539 + headers explicitly in addition to the normal gcc package.
99540 +
99541 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
99542 + bool "bts"
99543 + help
99544 + This method is compatible with binary only modules but has
99545 + a higher runtime overhead.
99546 +
99547 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
99548 + bool "or"
99549 + depends on !PARAVIRT
99550 + help
99551 + This method is incompatible with binary only modules but has
99552 + a lower runtime overhead.
99553 +endchoice
99554 +
99555 +config PAX_KERNEXEC_PLUGIN_METHOD
99556 + string
99557 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
99558 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
99559 + default ""
99560 +
99561 +config PAX_KERNEXEC_MODULE_TEXT
99562 + int "Minimum amount of memory reserved for module code"
99563 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
99564 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99565 + depends on PAX_KERNEXEC && X86_32
99566 + help
99567 + Due to implementation details the kernel must reserve a fixed
99568 + amount of memory for runtime allocated code (such as modules)
99569 + at compile time that cannot be changed at runtime. Here you
99570 + can specify the minimum amount in MB that will be reserved.
99571 + Due to the same implementation details this size will always
99572 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
99573 + the actually available memory for runtime allocated code will
99574 + usually be more than this minimum.
99575 +
99576 + The default 4 MB should be enough for most users but if you have
99577 + an excessive number of modules (e.g., most distribution configs
99578 + compile many drivers as modules) or use huge modules such as
99579 + nvidia's kernel driver, you will need to adjust this amount.
99580 + A good rule of thumb is to look at your currently loaded kernel
99581 + modules and add up their sizes.
99582 +
99583 +endmenu
99584 +
99585 +menu "Address Space Layout Randomization"
99586 + depends on PAX
99587 +
99588 +config PAX_ASLR
99589 + bool "Address Space Layout Randomization"
99590 + default y if GRKERNSEC_CONFIG_AUTO
99591 + help
99592 + Many if not most exploit techniques rely on the knowledge of
99593 + certain addresses in the attacked program. The following options
99594 + will allow the kernel to apply a certain amount of randomization
99595 + to specific parts of the program thereby forcing an attacker to
99596 + guess them in most cases. Any failed guess will most likely crash
99597 + the attacked program which allows the kernel to detect such attempts
99598 + and react on them. PaX itself provides no reaction mechanisms,
99599 + instead it is strongly encouraged that you make use of Nergal's
99600 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
99601 + (http://www.grsecurity.net/) built-in crash detection features or
99602 + develop one yourself.
99603 +
99604 + By saying Y here you can choose to randomize the following areas:
99605 + - top of the task's kernel stack
99606 + - top of the task's userland stack
99607 + - base address for mmap() requests that do not specify one
99608 + (this includes all libraries)
99609 + - base address of the main executable
99610 +
99611 + It is strongly recommended to say Y here as address space layout
99612 + randomization has negligible impact on performance yet it provides
99613 + a very effective protection.
99614 +
99615 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99616 + this feature on a per file basis.
99617 +
99618 +config PAX_RANDKSTACK
99619 + bool "Randomize kernel stack base"
99620 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
99621 + depends on X86_TSC && X86
99622 + help
99623 + By saying Y here the kernel will randomize every task's kernel
99624 + stack on every system call. This will not only force an attacker
99625 + to guess it but also prevent him from making use of possible
99626 + leaked information about it.
99627 +
99628 + Since the kernel stack is a rather scarce resource, randomization
99629 + may cause unexpected stack overflows, therefore you should very
99630 + carefully test your system. Note that once enabled in the kernel
99631 + configuration, this feature cannot be disabled on a per file basis.
99632 +
99633 +config PAX_RANDUSTACK
99634 + bool "Randomize user stack base"
99635 + default y if GRKERNSEC_CONFIG_AUTO
99636 + depends on PAX_ASLR
99637 + help
99638 + By saying Y here the kernel will randomize every task's userland
99639 + stack. The randomization is done in two steps where the second
99640 + one may apply a big amount of shift to the top of the stack and
99641 + cause problems for programs that want to use lots of memory (more
99642 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99643 + For this reason the second step can be controlled by 'chpax' or
99644 + 'paxctl' on a per file basis.
99645 +
99646 +config PAX_RANDMMAP
99647 + bool "Randomize mmap() base"
99648 + default y if GRKERNSEC_CONFIG_AUTO
99649 + depends on PAX_ASLR
99650 + help
99651 + By saying Y here the kernel will use a randomized base address for
99652 + mmap() requests that do not specify one themselves. As a result
99653 + all dynamically loaded libraries will appear at random addresses
99654 + and therefore be harder to exploit by a technique where an attacker
99655 + attempts to execute library code for his purposes (e.g. spawn a
99656 + shell from an exploited program that is running at an elevated
99657 + privilege level).
99658 +
99659 + Furthermore, if a program is relinked as a dynamic ELF file, its
99660 + base address will be randomized as well, completing the full
99661 + randomization of the address space layout. Attacking such programs
99662 + becomes a guess game. You can find an example of doing this at
99663 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99664 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99665 +
99666 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99667 + feature on a per file basis.
99668 +
99669 +endmenu
99670 +
99671 +menu "Miscellaneous hardening features"
99672 +
99673 +config PAX_MEMORY_SANITIZE
99674 + bool "Sanitize all freed memory"
99675 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99676 + depends on !HIBERNATION
99677 + help
99678 + By saying Y here the kernel will erase memory pages and slab objects
99679 + as soon as they are freed. This in turn reduces the lifetime of data
99680 + stored in them, making it less likely that sensitive information such
99681 + as passwords, cryptographic secrets, etc stay in memory for too long.
99682 +
99683 + This is especially useful for programs whose runtime is short, long
99684 + lived processes and the kernel itself benefit from this as long as
99685 + they ensure timely freeing of memory that may hold sensitive
99686 + information.
99687 +
99688 + A nice side effect of the sanitization of slab objects is the
99689 + reduction of possible info leaks caused by padding bytes within the
99690 + leaky structures. Use-after-free bugs for structures containing
99691 + pointers can also be detected as dereferencing the sanitized pointer
99692 + will generate an access violation.
99693 +
99694 + The tradeoff is performance impact, on a single CPU system kernel
99695 + compilation sees a 3% slowdown, other systems and workloads may vary
99696 + and you are advised to test this feature on your expected workload
99697 + before deploying it.
99698 +
99699 + To reduce the performance penalty by sanitizing pages only, albeit
99700 + limiting the effectiveness of this feature at the same time, slab
99701 + sanitization can be disabled with the kernel commandline parameter
99702 + "pax_sanitize_slab=0".
99703 +
99704 + Note that this feature does not protect data stored in live pages,
99705 + e.g., process memory swapped to disk may stay there for a long time.
99706 +
99707 +config PAX_MEMORY_STACKLEAK
99708 + bool "Sanitize kernel stack"
99709 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99710 + depends on X86
99711 + help
99712 + By saying Y here the kernel will erase the kernel stack before it
99713 + returns from a system call. This in turn reduces the information
99714 + that a kernel stack leak bug can reveal.
99715 +
99716 + Note that such a bug can still leak information that was put on
99717 + the stack by the current system call (the one eventually triggering
99718 + the bug) but traces of earlier system calls on the kernel stack
99719 + cannot leak anymore.
99720 +
99721 + The tradeoff is performance impact: on a single CPU system kernel
99722 + compilation sees a 1% slowdown, other systems and workloads may vary
99723 + and you are advised to test this feature on your expected workload
99724 + before deploying it.
99725 +
99726 + Note that the full feature 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. Using
99729 + older gcc versions means that functions with large enough stack
99730 + frames may leave uninitialized memory behind that may be exposed
99731 + to a later syscall leaking the stack.
99732 +
99733 +config PAX_MEMORY_STRUCTLEAK
99734 + bool "Forcibly initialize local variables copied to userland"
99735 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99736 + help
99737 + By saying Y here the kernel will zero initialize some local
99738 + variables that are going to be copied to userland. This in
99739 + turn prevents unintended information leakage from the kernel
99740 + stack should later code forget to explicitly set all parts of
99741 + the copied variable.
99742 +
99743 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
99744 + at a much smaller coverage.
99745 +
99746 + Note that the implementation requires a gcc with plugin support,
99747 + i.e., gcc 4.5 or newer. You may need to install the supporting
99748 + headers explicitly in addition to the normal gcc package.
99749 +
99750 +config PAX_MEMORY_UDEREF
99751 + bool "Prevent invalid userland pointer dereference"
99752 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
99753 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
99754 + select PAX_PER_CPU_PGD if X86_64
99755 + help
99756 + By saying Y here the kernel will be prevented from dereferencing
99757 + userland pointers in contexts where the kernel expects only kernel
99758 + pointers. This is both a useful runtime debugging feature and a
99759 + security measure that prevents exploiting a class of kernel bugs.
99760 +
99761 + The tradeoff is that some virtualization solutions may experience
99762 + a huge slowdown and therefore you should not enable this feature
99763 + for kernels meant to run in such environments. Whether a given VM
99764 + solution is affected or not is best determined by simply trying it
99765 + out, the performance impact will be obvious right on boot as this
99766 + mechanism engages from very early on. A good rule of thumb is that
99767 + VMs running on CPUs without hardware virtualization support (i.e.,
99768 + the majority of IA-32 CPUs) will likely experience the slowdown.
99769 +
99770 + On X86_64 the kernel will make use of PCID support when available
99771 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
99772 + or performance impact. Pass pax_weakuderef on the kernel command
99773 + line to choose the latter.
99774 +
99775 +config PAX_REFCOUNT
99776 + bool "Prevent various kernel object reference counter overflows"
99777 + default y if GRKERNSEC_CONFIG_AUTO
99778 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
99779 + help
99780 + By saying Y here the kernel will detect and prevent overflowing
99781 + various (but not all) kinds of object reference counters. Such
99782 + overflows can normally occur due to bugs only and are often, if
99783 + not always, exploitable.
99784 +
99785 + The tradeoff is that data structures protected by an overflowed
99786 + refcount will never be freed and therefore will leak memory. Note
99787 + that this leak also happens even without this protection but in
99788 + that case the overflow can eventually trigger the freeing of the
99789 + data structure while it is still being used elsewhere, resulting
99790 + in the exploitable situation that this feature prevents.
99791 +
99792 + Since this has a negligible performance impact, you should enable
99793 + this feature.
99794 +
99795 +config PAX_CONSTIFY_PLUGIN
99796 + bool "Automatically constify eligible structures"
99797 + default y
99798 + depends on !UML && PAX_KERNEXEC
99799 + help
99800 + By saying Y here the compiler will automatically constify a class
99801 + of types that contain only function pointers. This reduces the
99802 + kernel's attack surface and also produces a better memory layout.
99803 +
99804 + Note that the implementation requires a gcc with plugin support,
99805 + i.e., gcc 4.5 or newer. You may need to install the supporting
99806 + headers explicitly in addition to the normal gcc package.
99807 +
99808 + Note that if some code really has to modify constified variables
99809 + then the source code will have to be patched to allow it. Examples
99810 + can be found in PaX itself (the no_const attribute) and for some
99811 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
99812 +
99813 +config PAX_USERCOPY
99814 + bool "Harden heap object copies between kernel and userland"
99815 + default y if GRKERNSEC_CONFIG_AUTO
99816 + depends on ARM || IA64 || PPC || SPARC || X86
99817 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99818 + select PAX_USERCOPY_SLABS
99819 + help
99820 + By saying Y here the kernel will enforce the size of heap objects
99821 + when they are copied in either direction between the kernel and
99822 + userland, even if only a part of the heap object is copied.
99823 +
99824 + Specifically, this checking prevents information leaking from the
99825 + kernel heap during kernel to userland copies (if the kernel heap
99826 + object is otherwise fully initialized) and prevents kernel heap
99827 + overflows during userland to kernel copies.
99828 +
99829 + Note that the current implementation provides the strictest bounds
99830 + checks for the SLUB allocator.
99831 +
99832 + Enabling this option also enables per-slab cache protection against
99833 + data in a given cache being copied into/out of via userland
99834 + accessors. Though the whitelist of regions will be reduced over
99835 + time, it notably protects important data structures like task structs.
99836 +
99837 + If frame pointers are enabled on x86, this option will also restrict
99838 + copies into and out of the kernel stack to local variables within a
99839 + single frame.
99840 +
99841 + Since this has a negligible performance impact, you should enable
99842 + this feature.
99843 +
99844 +config PAX_USERCOPY_DEBUG
99845 + bool
99846 + depends on X86 && PAX_USERCOPY
99847 + default n
99848 +
99849 +config PAX_SIZE_OVERFLOW
99850 + bool "Prevent various integer overflows in function size parameters"
99851 + default y if GRKERNSEC_CONFIG_AUTO
99852 + depends on X86
99853 + help
99854 + By saying Y here the kernel recomputes expressions of function
99855 + arguments marked by a size_overflow attribute with double integer
99856 + precision (DImode/TImode for 32/64 bit integer types).
99857 +
99858 + The recomputed argument is checked against TYPE_MAX and an event
99859 + is logged on overflow and the triggering process is killed.
99860 +
99861 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99862 +
99863 + Note that the implementation requires a gcc with plugin support,
99864 + i.e., gcc 4.5 or newer. You may need to install the supporting
99865 + headers explicitly in addition to the normal gcc package.
99866 +
99867 +config PAX_LATENT_ENTROPY
99868 + bool "Generate some entropy during boot"
99869 + default y if GRKERNSEC_CONFIG_AUTO
99870 + help
99871 + By saying Y here the kernel will instrument early boot code to
99872 + extract some entropy from both original and artificially created
99873 + program state. This will help especially embedded systems where
99874 + there is little 'natural' source of entropy normally. The cost
99875 + is some slowdown of the boot process.
99876 +
99877 + When pax_extra_latent_entropy is passed on the kernel command line,
99878 + entropy will be extracted from up to the first 4GB of RAM while the
99879 + runtime memory allocator is being initialized. This costs even more
99880 + slowdown of the boot process.
99881 +
99882 + Note that the implementation requires a gcc with plugin support,
99883 + i.e., gcc 4.5 or newer. You may need to install the supporting
99884 + headers explicitly in addition to the normal gcc package.
99885 +
99886 + Note that entropy extracted this way is not cryptographically
99887 + secure!
99888 +
99889 +endmenu
99890 +
99891 +endmenu
99892 +
99893 +source grsecurity/Kconfig
99894 +
99895 +endmenu
99896 +
99897 +endmenu
99898 +
99899 source security/keys/Kconfig
99900
99901 config SECURITY_DMESG_RESTRICT
99902 @@ -103,7 +1056,7 @@ config INTEL_TXT
99903 config LSM_MMAP_MIN_ADDR
99904 int "Low address space for LSM to protect from user allocation"
99905 depends on SECURITY && SECURITY_SELINUX
99906 - default 32768 if ARM
99907 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99908 default 65536
99909 help
99910 This is the portion of low virtual memory which should be protected
99911 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
99912 index 9b9013b..51ebf96 100644
99913 --- a/security/apparmor/Kconfig
99914 +++ b/security/apparmor/Kconfig
99915 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
99916 boot.
99917
99918 If you are unsure how to answer this question, answer 1.
99919 +
99920 +config SECURITY_APPARMOR_COMPAT_24
99921 + bool "Enable AppArmor 2.4 compatability"
99922 + depends on SECURITY_APPARMOR
99923 + default y
99924 + help
99925 + This option enables compatability with AppArmor 2.4. It is
99926 + recommended if compatability with older versions of AppArmor
99927 + is desired.
99928 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
99929 index 16c15ec..42b7c9f 100644
99930 --- a/security/apparmor/apparmorfs.c
99931 +++ b/security/apparmor/apparmorfs.c
99932 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
99933 .release = single_release,
99934 };
99935
99936 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
99937 +/**
99938 + * __next_namespace - find the next namespace to list
99939 + * @root: root namespace to stop search at (NOT NULL)
99940 + * @ns: current ns position (NOT NULL)
99941 + *
99942 + * Find the next namespace from @ns under @root and handle all locking needed
99943 + * while switching current namespace.
99944 + *
99945 + * Returns: next namespace or NULL if at last namespace under @root
99946 + * NOTE: will not unlock root->lock
99947 + */
99948 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
99949 + struct aa_namespace *ns)
99950 +{
99951 + struct aa_namespace *parent;
99952 +
99953 + /* is next namespace a child */
99954 + if (!list_empty(&ns->sub_ns)) {
99955 + struct aa_namespace *next;
99956 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
99957 + read_lock(&next->lock);
99958 + return next;
99959 + }
99960 +
99961 + /* check if the next ns is a sibling, parent, gp, .. */
99962 + parent = ns->parent;
99963 + while (parent) {
99964 + read_unlock(&ns->lock);
99965 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
99966 + read_lock(&ns->lock);
99967 + return ns;
99968 + }
99969 + if (parent == root)
99970 + return NULL;
99971 + ns = parent;
99972 + parent = parent->parent;
99973 + }
99974 +
99975 + return NULL;
99976 +}
99977 +
99978 +/**
99979 + * __first_profile - find the first profile in a namespace
99980 + * @root: namespace that is root of profiles being displayed (NOT NULL)
99981 + * @ns: namespace to start in (NOT NULL)
99982 + *
99983 + * Returns: unrefcounted profile or NULL if no profile
99984 + */
99985 +static struct aa_profile *__first_profile(struct aa_namespace *root,
99986 + struct aa_namespace *ns)
99987 +{
99988 + for ( ; ns; ns = __next_namespace(root, ns)) {
99989 + if (!list_empty(&ns->base.profiles))
99990 + return list_first_entry(&ns->base.profiles,
99991 + struct aa_profile, base.list);
99992 + }
99993 + return NULL;
99994 +}
99995 +
99996 +/**
99997 + * __next_profile - step to the next profile in a profile tree
99998 + * @profile: current profile in tree (NOT NULL)
99999 + *
100000 + * Perform a depth first taversal on the profile tree in a namespace
100001 + *
100002 + * Returns: next profile or NULL if done
100003 + * Requires: profile->ns.lock to be held
100004 + */
100005 +static struct aa_profile *__next_profile(struct aa_profile *p)
100006 +{
100007 + struct aa_profile *parent;
100008 + struct aa_namespace *ns = p->ns;
100009 +
100010 + /* is next profile a child */
100011 + if (!list_empty(&p->base.profiles))
100012 + return list_first_entry(&p->base.profiles, typeof(*p),
100013 + base.list);
100014 +
100015 + /* is next profile a sibling, parent sibling, gp, subling, .. */
100016 + parent = p->parent;
100017 + while (parent) {
100018 + list_for_each_entry_continue(p, &parent->base.profiles,
100019 + base.list)
100020 + return p;
100021 + p = parent;
100022 + parent = parent->parent;
100023 + }
100024 +
100025 + /* is next another profile in the namespace */
100026 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
100027 + return p;
100028 +
100029 + return NULL;
100030 +}
100031 +
100032 +/**
100033 + * next_profile - step to the next profile in where ever it may be
100034 + * @root: root namespace (NOT NULL)
100035 + * @profile: current profile (NOT NULL)
100036 + *
100037 + * Returns: next profile or NULL if there isn't one
100038 + */
100039 +static struct aa_profile *next_profile(struct aa_namespace *root,
100040 + struct aa_profile *profile)
100041 +{
100042 + struct aa_profile *next = __next_profile(profile);
100043 + if (next)
100044 + return next;
100045 +
100046 + /* finished all profiles in namespace move to next namespace */
100047 + return __first_profile(root, __next_namespace(root, profile->ns));
100048 +}
100049 +
100050 +/**
100051 + * p_start - start a depth first traversal of profile tree
100052 + * @f: seq_file to fill
100053 + * @pos: current position
100054 + *
100055 + * Returns: first profile under current namespace or NULL if none found
100056 + *
100057 + * acquires first ns->lock
100058 + */
100059 +static void *p_start(struct seq_file *f, loff_t *pos)
100060 + __acquires(root->lock)
100061 +{
100062 + struct aa_profile *profile = NULL;
100063 + struct aa_namespace *root = aa_current_profile()->ns;
100064 + loff_t l = *pos;
100065 + f->private = aa_get_namespace(root);
100066 +
100067 +
100068 + /* find the first profile */
100069 + read_lock(&root->lock);
100070 + profile = __first_profile(root, root);
100071 +
100072 + /* skip to position */
100073 + for (; profile && l > 0; l--)
100074 + profile = next_profile(root, profile);
100075 +
100076 + return profile;
100077 +}
100078 +
100079 +/**
100080 + * p_next - read the next profile entry
100081 + * @f: seq_file to fill
100082 + * @p: profile previously returned
100083 + * @pos: current position
100084 + *
100085 + * Returns: next profile after @p or NULL if none
100086 + *
100087 + * may acquire/release locks in namespace tree as necessary
100088 + */
100089 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
100090 +{
100091 + struct aa_profile *profile = p;
100092 + struct aa_namespace *root = f->private;
100093 + (*pos)++;
100094 +
100095 + return next_profile(root, profile);
100096 +}
100097 +
100098 +/**
100099 + * p_stop - stop depth first traversal
100100 + * @f: seq_file we are filling
100101 + * @p: the last profile writen
100102 + *
100103 + * Release all locking done by p_start/p_next on namespace tree
100104 + */
100105 +static void p_stop(struct seq_file *f, void *p)
100106 + __releases(root->lock)
100107 +{
100108 + struct aa_profile *profile = p;
100109 + struct aa_namespace *root = f->private, *ns;
100110 +
100111 + if (profile) {
100112 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
100113 + read_unlock(&ns->lock);
100114 + }
100115 + read_unlock(&root->lock);
100116 + aa_put_namespace(root);
100117 +}
100118 +
100119 +/**
100120 + * seq_show_profile - show a profile entry
100121 + * @f: seq_file to file
100122 + * @p: current position (profile) (NOT NULL)
100123 + *
100124 + * Returns: error on failure
100125 + */
100126 +static int seq_show_profile(struct seq_file *f, void *p)
100127 +{
100128 + struct aa_profile *profile = (struct aa_profile *)p;
100129 + struct aa_namespace *root = f->private;
100130 +
100131 + if (profile->ns != root)
100132 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
100133 + seq_printf(f, "%s (%s)\n", profile->base.hname,
100134 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
100135 +
100136 + return 0;
100137 +}
100138 +
100139 +static const struct seq_operations aa_fs_profiles_op = {
100140 + .start = p_start,
100141 + .next = p_next,
100142 + .stop = p_stop,
100143 + .show = seq_show_profile,
100144 +};
100145 +
100146 +static int profiles_open(struct inode *inode, struct file *file)
100147 +{
100148 + return seq_open(file, &aa_fs_profiles_op);
100149 +}
100150 +
100151 +static int profiles_release(struct inode *inode, struct file *file)
100152 +{
100153 + return seq_release(inode, file);
100154 +}
100155 +
100156 +const struct file_operations aa_fs_profiles_fops = {
100157 + .open = profiles_open,
100158 + .read = seq_read,
100159 + .llseek = seq_lseek,
100160 + .release = profiles_release,
100161 +};
100162 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
100163 +
100164 /** Base file system setup **/
100165
100166 static struct aa_fs_entry aa_fs_entry_file[] = {
100167 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
100168 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
100169 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
100170 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
100171 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
100172 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
100173 +#endif
100174 AA_FS_DIR("features", aa_fs_entry_features),
100175 { }
100176 };
100177 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
100178 index b21830e..a7d1a17 100644
100179 --- a/security/apparmor/lsm.c
100180 +++ b/security/apparmor/lsm.c
100181 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
100182 return error;
100183 }
100184
100185 -static struct security_operations apparmor_ops = {
100186 +static struct security_operations apparmor_ops __read_only = {
100187 .name = "apparmor",
100188
100189 .ptrace_access_check = apparmor_ptrace_access_check,
100190 diff --git a/security/commoncap.c b/security/commoncap.c
100191 index c44b6fe..932df30 100644
100192 --- a/security/commoncap.c
100193 +++ b/security/commoncap.c
100194 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
100195 return 0;
100196 }
100197
100198 +/* returns:
100199 + 1 for suid privilege
100200 + 2 for sgid privilege
100201 + 3 for fscap privilege
100202 +*/
100203 +int is_privileged_binary(const struct dentry *dentry)
100204 +{
100205 + struct cpu_vfs_cap_data capdata;
100206 + struct inode *inode = dentry->d_inode;
100207 +
100208 + if (!inode || S_ISDIR(inode->i_mode))
100209 + return 0;
100210 +
100211 + if (inode->i_mode & S_ISUID)
100212 + return 1;
100213 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
100214 + return 2;
100215 +
100216 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
100217 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
100218 + return 3;
100219 + }
100220 +
100221 + return 0;
100222 +}
100223 +
100224 /*
100225 * Attempt to get the on-exec apply capability sets for an executable file from
100226 * its xattrs and, if present, apply them to the proposed credentials being
100227 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
100228 const struct cred *cred = current_cred();
100229 kuid_t root_uid = make_kuid(cred->user_ns, 0);
100230
100231 + if (gr_acl_enable_at_secure())
100232 + return 1;
100233 +
100234 if (!uid_eq(cred->uid, root_uid)) {
100235 if (bprm->cap_effective)
100236 return 1;
100237 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
100238 index a41c9c1..83da6dd 100644
100239 --- a/security/integrity/ima/ima.h
100240 +++ b/security/integrity/ima/ima.h
100241 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
100242 extern spinlock_t ima_queue_lock;
100243
100244 struct ima_h_table {
100245 - atomic_long_t len; /* number of stored measurements in the list */
100246 - atomic_long_t violations;
100247 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
100248 + atomic_long_unchecked_t violations;
100249 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
100250 };
100251 extern struct ima_h_table ima_htable;
100252 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
100253 index 1c03e8f1..398a941 100644
100254 --- a/security/integrity/ima/ima_api.c
100255 +++ b/security/integrity/ima/ima_api.c
100256 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
100257 int result;
100258
100259 /* can overflow, only indicator */
100260 - atomic_long_inc(&ima_htable.violations);
100261 + atomic_long_inc_unchecked(&ima_htable.violations);
100262
100263 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
100264 if (!entry) {
100265 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
100266 index 38477c9..87a60c7 100644
100267 --- a/security/integrity/ima/ima_fs.c
100268 +++ b/security/integrity/ima/ima_fs.c
100269 @@ -28,12 +28,12 @@
100270 static int valid_policy = 1;
100271 #define TMPBUFLEN 12
100272 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
100273 - loff_t *ppos, atomic_long_t *val)
100274 + loff_t *ppos, atomic_long_unchecked_t *val)
100275 {
100276 char tmpbuf[TMPBUFLEN];
100277 ssize_t len;
100278
100279 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
100280 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
100281 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
100282 }
100283
100284 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
100285 index ff63fe0..809cd96 100644
100286 --- a/security/integrity/ima/ima_queue.c
100287 +++ b/security/integrity/ima/ima_queue.c
100288 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
100289 INIT_LIST_HEAD(&qe->later);
100290 list_add_tail_rcu(&qe->later, &ima_measurements);
100291
100292 - atomic_long_inc(&ima_htable.len);
100293 + atomic_long_inc_unchecked(&ima_htable.len);
100294 key = ima_hash_key(entry->digest);
100295 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
100296 return 0;
100297 diff --git a/security/keys/compat.c b/security/keys/compat.c
100298 index d65fa7f..cbfe366 100644
100299 --- a/security/keys/compat.c
100300 +++ b/security/keys/compat.c
100301 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
100302 if (ret == 0)
100303 goto no_payload_free;
100304
100305 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100306 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100307 err:
100308 if (iov != iovstack)
100309 kfree(iov);
100310 diff --git a/security/keys/internal.h b/security/keys/internal.h
100311 index d4f1468..cc52f92 100644
100312 --- a/security/keys/internal.h
100313 +++ b/security/keys/internal.h
100314 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
100315 extern long keyctl_invalidate_key(key_serial_t);
100316
100317 extern long keyctl_instantiate_key_common(key_serial_t,
100318 - const struct iovec *,
100319 + const struct iovec __user *,
100320 unsigned, size_t, key_serial_t);
100321
100322 /*
100323 diff --git a/security/keys/key.c b/security/keys/key.c
100324 index 8fb7c7b..ba3610d 100644
100325 --- a/security/keys/key.c
100326 +++ b/security/keys/key.c
100327 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
100328
100329 atomic_set(&key->usage, 1);
100330 init_rwsem(&key->sem);
100331 - lockdep_set_class(&key->sem, &type->lock_class);
100332 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
100333 key->type = type;
100334 key->user = user;
100335 key->quotalen = quotalen;
100336 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
100337 struct key_type *p;
100338 int ret;
100339
100340 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
100341 + pax_open_kernel();
100342 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
100343 + pax_close_kernel();
100344
100345 ret = -EEXIST;
100346 down_write(&key_types_sem);
100347 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
100348 }
100349
100350 /* store the type */
100351 - list_add(&ktype->link, &key_types_list);
100352 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
100353
100354 pr_notice("Key type %s registered\n", ktype->name);
100355 ret = 0;
100356 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
100357 void unregister_key_type(struct key_type *ktype)
100358 {
100359 down_write(&key_types_sem);
100360 - list_del_init(&ktype->link);
100361 + pax_list_del_init((struct list_head *)&ktype->link);
100362 downgrade_write(&key_types_sem);
100363 key_gc_keytype(ktype);
100364 pr_notice("Key type %s unregistered\n", ktype->name);
100365 @@ -1084,10 +1086,10 @@ void __init key_init(void)
100366 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
100367
100368 /* add the special key types */
100369 - list_add_tail(&key_type_keyring.link, &key_types_list);
100370 - list_add_tail(&key_type_dead.link, &key_types_list);
100371 - list_add_tail(&key_type_user.link, &key_types_list);
100372 - list_add_tail(&key_type_logon.link, &key_types_list);
100373 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
100374 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
100375 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
100376 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
100377
100378 /* record the root user tracking */
100379 rb_link_node(&root_key_user.node,
100380 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
100381 index 33cfd27..842fc5a 100644
100382 --- a/security/keys/keyctl.c
100383 +++ b/security/keys/keyctl.c
100384 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
100385 /*
100386 * Copy the iovec data from userspace
100387 */
100388 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100389 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
100390 unsigned ioc)
100391 {
100392 for (; ioc > 0; ioc--) {
100393 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100394 * If successful, 0 will be returned.
100395 */
100396 long keyctl_instantiate_key_common(key_serial_t id,
100397 - const struct iovec *payload_iov,
100398 + const struct iovec __user *payload_iov,
100399 unsigned ioc,
100400 size_t plen,
100401 key_serial_t ringid)
100402 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
100403 [0].iov_len = plen
100404 };
100405
100406 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
100407 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
100408 }
100409
100410 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
100411 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
100412 if (ret == 0)
100413 goto no_payload_free;
100414
100415 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100416 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100417 err:
100418 if (iov != iovstack)
100419 kfree(iov);
100420 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
100421 index 6ece7f2..ecdb55c 100644
100422 --- a/security/keys/keyring.c
100423 +++ b/security/keys/keyring.c
100424 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
100425 ret = -EFAULT;
100426
100427 for (loop = 0; loop < klist->nkeys; loop++) {
100428 + key_serial_t serial;
100429 key = rcu_deref_link_locked(klist, loop,
100430 keyring);
100431 + serial = key->serial;
100432
100433 tmp = sizeof(key_serial_t);
100434 if (tmp > buflen)
100435 tmp = buflen;
100436
100437 - if (copy_to_user(buffer,
100438 - &key->serial,
100439 - tmp) != 0)
100440 + if (copy_to_user(buffer, &serial, tmp))
100441 goto error;
100442
100443 buflen -= tmp;
100444 diff --git a/security/min_addr.c b/security/min_addr.c
100445 index f728728..6457a0c 100644
100446 --- a/security/min_addr.c
100447 +++ b/security/min_addr.c
100448 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
100449 */
100450 static void update_mmap_min_addr(void)
100451 {
100452 +#ifndef SPARC
100453 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
100454 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
100455 mmap_min_addr = dac_mmap_min_addr;
100456 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
100457 #else
100458 mmap_min_addr = dac_mmap_min_addr;
100459 #endif
100460 +#endif
100461 }
100462
100463 /*
100464 diff --git a/security/security.c b/security/security.c
100465 index a3dce87..04178a1 100644
100466 --- a/security/security.c
100467 +++ b/security/security.c
100468 @@ -20,6 +20,7 @@
100469 #include <linux/ima.h>
100470 #include <linux/evm.h>
100471 #include <linux/fsnotify.h>
100472 +#include <linux/mm.h>
100473 #include <linux/mman.h>
100474 #include <linux/mount.h>
100475 #include <linux/personality.h>
100476 @@ -32,8 +33,8 @@
100477 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
100478 CONFIG_DEFAULT_SECURITY;
100479
100480 -static struct security_operations *security_ops;
100481 -static struct security_operations default_security_ops = {
100482 +static struct security_operations *security_ops __read_only;
100483 +static struct security_operations default_security_ops __read_only = {
100484 .name = "default",
100485 };
100486
100487 @@ -72,11 +73,17 @@ int __init security_init(void)
100488 return 0;
100489 }
100490
100491 +#ifdef CONFIG_SECURITY_SELINUX_DISABLE
100492 +
100493 void reset_security_ops(void)
100494 {
100495 + pax_open_kernel();
100496 security_ops = &default_security_ops;
100497 + pax_close_kernel();
100498 }
100499
100500 +#endif
100501 +
100502 /* Save user chosen LSM */
100503 static int __init choose_lsm(char *str)
100504 {
100505 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
100506 index dad36a6..7e5ffbf 100644
100507 --- a/security/selinux/avc.c
100508 +++ b/security/selinux/avc.c
100509 @@ -59,7 +59,7 @@ struct avc_node {
100510 struct avc_cache {
100511 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
100512 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
100513 - atomic_t lru_hint; /* LRU hint for reclaim scan */
100514 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
100515 atomic_t active_nodes;
100516 u32 latest_notif; /* latest revocation notification */
100517 };
100518 @@ -167,7 +167,7 @@ void __init avc_init(void)
100519 spin_lock_init(&avc_cache.slots_lock[i]);
100520 }
100521 atomic_set(&avc_cache.active_nodes, 0);
100522 - atomic_set(&avc_cache.lru_hint, 0);
100523 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
100524
100525 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
100526 0, SLAB_PANIC, NULL);
100527 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
100528 spinlock_t *lock;
100529
100530 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
100531 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100532 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100533 head = &avc_cache.slots[hvalue];
100534 lock = &avc_cache.slots_lock[hvalue];
100535
100536 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
100537 index 5c6f2cd..b4f945c 100644
100538 --- a/security/selinux/hooks.c
100539 +++ b/security/selinux/hooks.c
100540 @@ -96,8 +96,6 @@
100541
100542 #define NUM_SEL_MNT_OPTS 5
100543
100544 -extern struct security_operations *security_ops;
100545 -
100546 /* SECMARK reference count */
100547 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
100548
100549 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
100550
100551 #endif
100552
100553 -static struct security_operations selinux_ops = {
100554 +static struct security_operations selinux_ops __read_only = {
100555 .name = "selinux",
100556
100557 .ptrace_access_check = selinux_ptrace_access_check,
100558 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
100559 index 65f67cb..3f141ef 100644
100560 --- a/security/selinux/include/xfrm.h
100561 +++ b/security/selinux/include/xfrm.h
100562 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
100563
100564 static inline void selinux_xfrm_notify_policyload(void)
100565 {
100566 - atomic_inc(&flow_cache_genid);
100567 + atomic_inc_unchecked(&flow_cache_genid);
100568 rt_genid_bump(&init_net);
100569 }
100570 #else
100571 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
100572 index d52c780..6431349 100644
100573 --- a/security/smack/smack_lsm.c
100574 +++ b/security/smack/smack_lsm.c
100575 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
100576 return 0;
100577 }
100578
100579 -struct security_operations smack_ops = {
100580 +struct security_operations smack_ops __read_only = {
100581 .name = "smack",
100582
100583 .ptrace_access_check = smack_ptrace_access_check,
100584 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
100585 index 390c646..f2f8db3 100644
100586 --- a/security/tomoyo/mount.c
100587 +++ b/security/tomoyo/mount.c
100588 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
100589 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
100590 need_dev = -1; /* dev_name is a directory */
100591 } else {
100592 + if (!capable(CAP_SYS_ADMIN)) {
100593 + error = -EPERM;
100594 + goto out;
100595 + }
100596 fstype = get_fs_type(type);
100597 if (!fstype) {
100598 error = -ENODEV;
100599 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
100600 index f0b756e..b129202 100644
100601 --- a/security/tomoyo/tomoyo.c
100602 +++ b/security/tomoyo/tomoyo.c
100603 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
100604 * tomoyo_security_ops is a "struct security_operations" which is used for
100605 * registering TOMOYO.
100606 */
100607 -static struct security_operations tomoyo_security_ops = {
100608 +static struct security_operations tomoyo_security_ops __read_only = {
100609 .name = "tomoyo",
100610 .cred_alloc_blank = tomoyo_cred_alloc_blank,
100611 .cred_prepare = tomoyo_cred_prepare,
100612 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
100613 index 20ef514..4182bed 100644
100614 --- a/security/yama/Kconfig
100615 +++ b/security/yama/Kconfig
100616 @@ -1,6 +1,6 @@
100617 config SECURITY_YAMA
100618 bool "Yama support"
100619 - depends on SECURITY
100620 + depends on SECURITY && !GRKERNSEC
100621 select SECURITYFS
100622 select SECURITY_PATH
100623 default n
100624 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
100625 index 13c88fbc..f8c115e 100644
100626 --- a/security/yama/yama_lsm.c
100627 +++ b/security/yama/yama_lsm.c
100628 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
100629 }
100630
100631 #ifndef CONFIG_SECURITY_YAMA_STACKED
100632 -static struct security_operations yama_ops = {
100633 +static struct security_operations yama_ops __read_only = {
100634 .name = "yama",
100635
100636 .ptrace_access_check = yama_ptrace_access_check,
100637 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
100638 #endif
100639
100640 #ifdef CONFIG_SYSCTL
100641 +static int zero __read_only;
100642 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
100643 +
100644 static int yama_dointvec_minmax(struct ctl_table *table, int write,
100645 void __user *buffer, size_t *lenp, loff_t *ppos)
100646 {
100647 - int rc;
100648 + ctl_table_no_const yama_table;
100649
100650 if (write && !capable(CAP_SYS_PTRACE))
100651 return -EPERM;
100652
100653 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
100654 - if (rc)
100655 - return rc;
100656 -
100657 + yama_table = *table;
100658 /* Lock the max value if it ever gets set. */
100659 - if (write && *(int *)table->data == *(int *)table->extra2)
100660 - table->extra1 = table->extra2;
100661 -
100662 - return rc;
100663 + if (ptrace_scope == max_scope)
100664 + yama_table.extra1 = &max_scope;
100665 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
100666 }
100667
100668 -static int zero;
100669 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
100670 -
100671 struct ctl_path yama_sysctl_path[] = {
100672 { .procname = "kernel", },
100673 { .procname = "yama", },
100674 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
100675 index 4cedc69..e59d8a3 100644
100676 --- a/sound/aoa/codecs/onyx.c
100677 +++ b/sound/aoa/codecs/onyx.c
100678 @@ -54,7 +54,7 @@ struct onyx {
100679 spdif_locked:1,
100680 analog_locked:1,
100681 original_mute:2;
100682 - int open_count;
100683 + local_t open_count;
100684 struct codec_info *codec_info;
100685
100686 /* mutex serializes concurrent access to the device
100687 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
100688 struct onyx *onyx = cii->codec_data;
100689
100690 mutex_lock(&onyx->mutex);
100691 - onyx->open_count++;
100692 + local_inc(&onyx->open_count);
100693 mutex_unlock(&onyx->mutex);
100694
100695 return 0;
100696 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
100697 struct onyx *onyx = cii->codec_data;
100698
100699 mutex_lock(&onyx->mutex);
100700 - onyx->open_count--;
100701 - if (!onyx->open_count)
100702 + if (local_dec_and_test(&onyx->open_count))
100703 onyx->spdif_locked = onyx->analog_locked = 0;
100704 mutex_unlock(&onyx->mutex);
100705
100706 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
100707 index ffd2025..df062c9 100644
100708 --- a/sound/aoa/codecs/onyx.h
100709 +++ b/sound/aoa/codecs/onyx.h
100710 @@ -11,6 +11,7 @@
100711 #include <linux/i2c.h>
100712 #include <asm/pmac_low_i2c.h>
100713 #include <asm/prom.h>
100714 +#include <asm/local.h>
100715
100716 /* PCM3052 register definitions */
100717
100718 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
100719 index 4c1cc51..16040040 100644
100720 --- a/sound/core/oss/pcm_oss.c
100721 +++ b/sound/core/oss/pcm_oss.c
100722 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
100723 if (in_kernel) {
100724 mm_segment_t fs;
100725 fs = snd_enter_user();
100726 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100727 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100728 snd_leave_user(fs);
100729 } else {
100730 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100731 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100732 }
100733 if (ret != -EPIPE && ret != -ESTRPIPE)
100734 break;
100735 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
100736 if (in_kernel) {
100737 mm_segment_t fs;
100738 fs = snd_enter_user();
100739 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100740 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100741 snd_leave_user(fs);
100742 } else {
100743 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100744 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100745 }
100746 if (ret == -EPIPE) {
100747 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
100748 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
100749 struct snd_pcm_plugin_channel *channels;
100750 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
100751 if (!in_kernel) {
100752 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
100753 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
100754 return -EFAULT;
100755 buf = runtime->oss.buffer;
100756 }
100757 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
100758 }
100759 } else {
100760 tmp = snd_pcm_oss_write2(substream,
100761 - (const char __force *)buf,
100762 + (const char __force_kernel *)buf,
100763 runtime->oss.period_bytes, 0);
100764 if (tmp <= 0)
100765 goto err;
100766 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
100767 struct snd_pcm_runtime *runtime = substream->runtime;
100768 snd_pcm_sframes_t frames, frames1;
100769 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
100770 - char __user *final_dst = (char __force __user *)buf;
100771 + char __user *final_dst = (char __force_user *)buf;
100772 if (runtime->oss.plugin_first) {
100773 struct snd_pcm_plugin_channel *channels;
100774 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
100775 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
100776 xfer += tmp;
100777 runtime->oss.buffer_used -= tmp;
100778 } else {
100779 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
100780 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
100781 runtime->oss.period_bytes, 0);
100782 if (tmp <= 0)
100783 goto err;
100784 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
100785 size1);
100786 size1 /= runtime->channels; /* frames */
100787 fs = snd_enter_user();
100788 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
100789 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
100790 snd_leave_user(fs);
100791 }
100792 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
100793 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
100794 index af49721..e85058e 100644
100795 --- a/sound/core/pcm_compat.c
100796 +++ b/sound/core/pcm_compat.c
100797 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
100798 int err;
100799
100800 fs = snd_enter_user();
100801 - err = snd_pcm_delay(substream, &delay);
100802 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
100803 snd_leave_user(fs);
100804 if (err < 0)
100805 return err;
100806 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
100807 index f928181..33fb83d 100644
100808 --- a/sound/core/pcm_native.c
100809 +++ b/sound/core/pcm_native.c
100810 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
100811 switch (substream->stream) {
100812 case SNDRV_PCM_STREAM_PLAYBACK:
100813 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
100814 - (void __user *)arg);
100815 + (void __force_user *)arg);
100816 break;
100817 case SNDRV_PCM_STREAM_CAPTURE:
100818 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
100819 - (void __user *)arg);
100820 + (void __force_user *)arg);
100821 break;
100822 default:
100823 result = -EINVAL;
100824 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
100825 index 040c60e..989a19a 100644
100826 --- a/sound/core/seq/seq_device.c
100827 +++ b/sound/core/seq/seq_device.c
100828 @@ -64,7 +64,7 @@ struct ops_list {
100829 int argsize; /* argument size */
100830
100831 /* operators */
100832 - struct snd_seq_dev_ops ops;
100833 + struct snd_seq_dev_ops *ops;
100834
100835 /* registered devices */
100836 struct list_head dev_list; /* list of devices */
100837 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
100838
100839 mutex_lock(&ops->reg_mutex);
100840 /* copy driver operators */
100841 - ops->ops = *entry;
100842 + ops->ops = entry;
100843 ops->driver |= DRIVER_LOADED;
100844 ops->argsize = argsize;
100845
100846 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
100847 dev->name, ops->id, ops->argsize, dev->argsize);
100848 return -EINVAL;
100849 }
100850 - if (ops->ops.init_device(dev) >= 0) {
100851 + if (ops->ops->init_device(dev) >= 0) {
100852 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
100853 ops->num_init_devices++;
100854 } else {
100855 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
100856 dev->name, ops->id, ops->argsize, dev->argsize);
100857 return -EINVAL;
100858 }
100859 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
100860 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
100861 dev->status = SNDRV_SEQ_DEVICE_FREE;
100862 dev->driver_data = NULL;
100863 ops->num_init_devices--;
100864 diff --git a/sound/core/sound.c b/sound/core/sound.c
100865 index f002bd9..c462985 100644
100866 --- a/sound/core/sound.c
100867 +++ b/sound/core/sound.c
100868 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
100869 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
100870 default: return;
100871 }
100872 - request_module(str);
100873 + request_module("%s", str);
100874 }
100875
100876 #endif /* modular kernel */
100877 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
100878 index 4e0dd22..7a1f32c 100644
100879 --- a/sound/drivers/mts64.c
100880 +++ b/sound/drivers/mts64.c
100881 @@ -29,6 +29,7 @@
100882 #include <sound/initval.h>
100883 #include <sound/rawmidi.h>
100884 #include <sound/control.h>
100885 +#include <asm/local.h>
100886
100887 #define CARD_NAME "Miditerminal 4140"
100888 #define DRIVER_NAME "MTS64"
100889 @@ -67,7 +68,7 @@ struct mts64 {
100890 struct pardevice *pardev;
100891 int pardev_claimed;
100892
100893 - int open_count;
100894 + local_t open_count;
100895 int current_midi_output_port;
100896 int current_midi_input_port;
100897 u8 mode[MTS64_NUM_INPUT_PORTS];
100898 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100899 {
100900 struct mts64 *mts = substream->rmidi->private_data;
100901
100902 - if (mts->open_count == 0) {
100903 + if (local_read(&mts->open_count) == 0) {
100904 /* We don't need a spinlock here, because this is just called
100905 if the device has not been opened before.
100906 So there aren't any IRQs from the device */
100907 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100908
100909 msleep(50);
100910 }
100911 - ++(mts->open_count);
100912 + local_inc(&mts->open_count);
100913
100914 return 0;
100915 }
100916 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100917 struct mts64 *mts = substream->rmidi->private_data;
100918 unsigned long flags;
100919
100920 - --(mts->open_count);
100921 - if (mts->open_count == 0) {
100922 + if (local_dec_return(&mts->open_count) == 0) {
100923 /* We need the spinlock_irqsave here because we can still
100924 have IRQs at this point */
100925 spin_lock_irqsave(&mts->lock, flags);
100926 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100927
100928 msleep(500);
100929
100930 - } else if (mts->open_count < 0)
100931 - mts->open_count = 0;
100932 + } else if (local_read(&mts->open_count) < 0)
100933 + local_set(&mts->open_count, 0);
100934
100935 return 0;
100936 }
100937 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100938 index b953fb4..1999c01 100644
100939 --- a/sound/drivers/opl4/opl4_lib.c
100940 +++ b/sound/drivers/opl4/opl4_lib.c
100941 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100942 MODULE_DESCRIPTION("OPL4 driver");
100943 MODULE_LICENSE("GPL");
100944
100945 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100946 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100947 {
100948 int timeout = 10;
100949 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100950 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100951 index 991018d..8984740 100644
100952 --- a/sound/drivers/portman2x4.c
100953 +++ b/sound/drivers/portman2x4.c
100954 @@ -48,6 +48,7 @@
100955 #include <sound/initval.h>
100956 #include <sound/rawmidi.h>
100957 #include <sound/control.h>
100958 +#include <asm/local.h>
100959
100960 #define CARD_NAME "Portman 2x4"
100961 #define DRIVER_NAME "portman"
100962 @@ -85,7 +86,7 @@ struct portman {
100963 struct pardevice *pardev;
100964 int pardev_claimed;
100965
100966 - int open_count;
100967 + local_t open_count;
100968 int mode[PORTMAN_NUM_INPUT_PORTS];
100969 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100970 };
100971 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100972 index ea995af..f1bfa37 100644
100973 --- a/sound/firewire/amdtp.c
100974 +++ b/sound/firewire/amdtp.c
100975 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100976 ptr = s->pcm_buffer_pointer + data_blocks;
100977 if (ptr >= pcm->runtime->buffer_size)
100978 ptr -= pcm->runtime->buffer_size;
100979 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100980 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100981
100982 s->pcm_period_pointer += data_blocks;
100983 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100984 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100985 */
100986 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100987 {
100988 - ACCESS_ONCE(s->source_node_id_field) =
100989 + ACCESS_ONCE_RW(s->source_node_id_field) =
100990 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100991 }
100992 EXPORT_SYMBOL(amdtp_out_stream_update);
100993 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100994 index b680c5e..061b7a0 100644
100995 --- a/sound/firewire/amdtp.h
100996 +++ b/sound/firewire/amdtp.h
100997 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100998 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100999 struct snd_pcm_substream *pcm)
101000 {
101001 - ACCESS_ONCE(s->pcm) = pcm;
101002 + ACCESS_ONCE_RW(s->pcm) = pcm;
101003 }
101004
101005 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
101006 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
101007 index d428ffe..751ef78 100644
101008 --- a/sound/firewire/isight.c
101009 +++ b/sound/firewire/isight.c
101010 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
101011 ptr += count;
101012 if (ptr >= runtime->buffer_size)
101013 ptr -= runtime->buffer_size;
101014 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
101015 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
101016
101017 isight->period_counter += count;
101018 if (isight->period_counter >= runtime->period_size) {
101019 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
101020 if (err < 0)
101021 return err;
101022
101023 - ACCESS_ONCE(isight->pcm_active) = true;
101024 + ACCESS_ONCE_RW(isight->pcm_active) = true;
101025
101026 return 0;
101027 }
101028 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
101029 {
101030 struct isight *isight = substream->private_data;
101031
101032 - ACCESS_ONCE(isight->pcm_active) = false;
101033 + ACCESS_ONCE_RW(isight->pcm_active) = false;
101034
101035 mutex_lock(&isight->mutex);
101036 isight_stop_streaming(isight);
101037 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
101038
101039 switch (cmd) {
101040 case SNDRV_PCM_TRIGGER_START:
101041 - ACCESS_ONCE(isight->pcm_running) = true;
101042 + ACCESS_ONCE_RW(isight->pcm_running) = true;
101043 break;
101044 case SNDRV_PCM_TRIGGER_STOP:
101045 - ACCESS_ONCE(isight->pcm_running) = false;
101046 + ACCESS_ONCE_RW(isight->pcm_running) = false;
101047 break;
101048 default:
101049 return -EINVAL;
101050 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
101051 index 844a555..985ab83 100644
101052 --- a/sound/firewire/scs1x.c
101053 +++ b/sound/firewire/scs1x.c
101054 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
101055 {
101056 struct scs *scs = stream->rmidi->private_data;
101057
101058 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
101059 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
101060 if (up) {
101061 scs->output_idle = false;
101062 tasklet_schedule(&scs->tasklet);
101063 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
101064 {
101065 struct scs *scs = stream->rmidi->private_data;
101066
101067 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
101068 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
101069 }
101070
101071 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
101072 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
101073
101074 snd_card_disconnect(scs->card);
101075
101076 - ACCESS_ONCE(scs->output) = NULL;
101077 - ACCESS_ONCE(scs->input) = NULL;
101078 + ACCESS_ONCE_RW(scs->output) = NULL;
101079 + ACCESS_ONCE_RW(scs->input) = NULL;
101080
101081 wait_event(scs->idle_wait, scs->output_idle);
101082
101083 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
101084 index 048439a..3be9f6f 100644
101085 --- a/sound/oss/sb_audio.c
101086 +++ b/sound/oss/sb_audio.c
101087 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
101088 buf16 = (signed short *)(localbuf + localoffs);
101089 while (c)
101090 {
101091 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101092 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101093 if (copy_from_user(lbuf8,
101094 userbuf+useroffs + p,
101095 locallen))
101096 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
101097 index 7d8803a..559f8d0 100644
101098 --- a/sound/oss/swarm_cs4297a.c
101099 +++ b/sound/oss/swarm_cs4297a.c
101100 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
101101 {
101102 struct cs4297a_state *s;
101103 u32 pwr, id;
101104 - mm_segment_t fs;
101105 int rval;
101106 #ifndef CONFIG_BCM_CS4297A_CSWARM
101107 u64 cfg;
101108 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
101109 if (!rval) {
101110 char *sb1250_duart_present;
101111
101112 +#if 0
101113 + mm_segment_t fs;
101114 fs = get_fs();
101115 set_fs(KERNEL_DS);
101116 -#if 0
101117 val = SOUND_MASK_LINE;
101118 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
101119 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
101120 val = initvol[i].vol;
101121 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
101122 }
101123 + set_fs(fs);
101124 // cs4297a_write_ac97(s, 0x18, 0x0808);
101125 #else
101126 // cs4297a_write_ac97(s, 0x5e, 0x180);
101127 cs4297a_write_ac97(s, 0x02, 0x0808);
101128 cs4297a_write_ac97(s, 0x18, 0x0808);
101129 #endif
101130 - set_fs(fs);
101131
101132 list_add(&s->list, &cs4297a_devs);
101133
101134 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
101135 index 55108b5..d973e11 100644
101136 --- a/sound/pci/hda/hda_codec.c
101137 +++ b/sound/pci/hda/hda_codec.c
101138 @@ -916,14 +916,10 @@ find_codec_preset(struct hda_codec *codec)
101139 mutex_unlock(&preset_mutex);
101140
101141 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
101142 - char name[32];
101143 if (!mod_requested)
101144 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
101145 - codec->vendor_id);
101146 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
101147 else
101148 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
101149 - (codec->vendor_id >> 16) & 0xffff);
101150 - request_module(name);
101151 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
101152 mod_requested++;
101153 goto again;
101154 }
101155 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
101156 index 4631a23..001ae57 100644
101157 --- a/sound/pci/ymfpci/ymfpci.h
101158 +++ b/sound/pci/ymfpci/ymfpci.h
101159 @@ -358,7 +358,7 @@ struct snd_ymfpci {
101160 spinlock_t reg_lock;
101161 spinlock_t voice_lock;
101162 wait_queue_head_t interrupt_sleep;
101163 - atomic_t interrupt_sleep_count;
101164 + atomic_unchecked_t interrupt_sleep_count;
101165 struct snd_info_entry *proc_entry;
101166 const struct firmware *dsp_microcode;
101167 const struct firmware *controller_microcode;
101168 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
101169 index 22056c5..25d3244 100644
101170 --- a/sound/pci/ymfpci/ymfpci_main.c
101171 +++ b/sound/pci/ymfpci/ymfpci_main.c
101172 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
101173 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
101174 break;
101175 }
101176 - if (atomic_read(&chip->interrupt_sleep_count)) {
101177 - atomic_set(&chip->interrupt_sleep_count, 0);
101178 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101179 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101180 wake_up(&chip->interrupt_sleep);
101181 }
101182 __end:
101183 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
101184 continue;
101185 init_waitqueue_entry(&wait, current);
101186 add_wait_queue(&chip->interrupt_sleep, &wait);
101187 - atomic_inc(&chip->interrupt_sleep_count);
101188 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
101189 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
101190 remove_wait_queue(&chip->interrupt_sleep, &wait);
101191 }
101192 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
101193 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
101194 spin_unlock(&chip->reg_lock);
101195
101196 - if (atomic_read(&chip->interrupt_sleep_count)) {
101197 - atomic_set(&chip->interrupt_sleep_count, 0);
101198 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101199 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101200 wake_up(&chip->interrupt_sleep);
101201 }
101202 }
101203 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
101204 spin_lock_init(&chip->reg_lock);
101205 spin_lock_init(&chip->voice_lock);
101206 init_waitqueue_head(&chip->interrupt_sleep);
101207 - atomic_set(&chip->interrupt_sleep_count, 0);
101208 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101209 chip->card = card;
101210 chip->pci = pci;
101211 chip->irq = -1;
101212 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
101213 index 0f0bed6..c161e28 100644
101214 --- a/sound/soc/fsl/fsl_ssi.c
101215 +++ b/sound/soc/fsl/fsl_ssi.c
101216 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
101217 {
101218 struct fsl_ssi_private *ssi_private;
101219 int ret = 0;
101220 - struct device_attribute *dev_attr = NULL;
101221 + device_attribute_no_const *dev_attr = NULL;
101222 struct device_node *np = pdev->dev.of_node;
101223 const char *p, *sprop;
101224 const uint32_t *iprop;
101225 diff --git a/sound/sound_core.c b/sound/sound_core.c
101226 index 359753f..45759f4 100644
101227 --- a/sound/sound_core.c
101228 +++ b/sound/sound_core.c
101229 @@ -292,7 +292,7 @@ retry:
101230 }
101231
101232 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
101233 - NULL, s->name+6);
101234 + NULL, "%s", s->name+6);
101235 return s->unit_minor;
101236
101237 fail:
101238 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
101239 new file mode 100644
101240 index 0000000..50f2f2f
101241 --- /dev/null
101242 +++ b/tools/gcc/.gitignore
101243 @@ -0,0 +1 @@
101244 +size_overflow_hash.h
101245 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
101246 new file mode 100644
101247 index 0000000..144dbee
101248 --- /dev/null
101249 +++ b/tools/gcc/Makefile
101250 @@ -0,0 +1,45 @@
101251 +#CC := gcc
101252 +#PLUGIN_SOURCE_FILES := pax_plugin.c
101253 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
101254 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
101255 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
101256 +
101257 +ifeq ($(PLUGINCC),$(HOSTCC))
101258 +HOSTLIBS := hostlibs
101259 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
101260 +else
101261 +HOSTLIBS := hostcxxlibs
101262 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
101263 +endif
101264 +
101265 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
101266 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
101267 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
101268 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
101269 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
101270 +$(HOSTLIBS)-y += colorize_plugin.so
101271 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
101272 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
101273 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
101274 +
101275 +always := $($(HOSTLIBS)-y)
101276 +
101277 +constify_plugin-objs := constify_plugin.o
101278 +stackleak_plugin-objs := stackleak_plugin.o
101279 +kallocstat_plugin-objs := kallocstat_plugin.o
101280 +kernexec_plugin-objs := kernexec_plugin.o
101281 +checker_plugin-objs := checker_plugin.o
101282 +colorize_plugin-objs := colorize_plugin.o
101283 +size_overflow_plugin-objs := size_overflow_plugin.o
101284 +latent_entropy_plugin-objs := latent_entropy_plugin.o
101285 +structleak_plugin-objs := structleak_plugin.o
101286 +
101287 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
101288 +
101289 +quiet_cmd_build_size_overflow_hash = GENHASH $@
101290 + cmd_build_size_overflow_hash = \
101291 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
101292 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
101293 + $(call if_changed,build_size_overflow_hash)
101294 +
101295 +targets += size_overflow_hash.h
101296 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
101297 new file mode 100644
101298 index 0000000..22f03c0
101299 --- /dev/null
101300 +++ b/tools/gcc/checker_plugin.c
101301 @@ -0,0 +1,172 @@
101302 +/*
101303 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
101304 + * Licensed under the GPL v2
101305 + *
101306 + * Note: the choice of the license means that the compilation process is
101307 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101308 + * but for the kernel it doesn't matter since it doesn't link against
101309 + * any of the gcc libraries
101310 + *
101311 + * gcc plugin to implement various sparse (source code checker) features
101312 + *
101313 + * TODO:
101314 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
101315 + *
101316 + * BUGS:
101317 + * - none known
101318 + */
101319 +#include "gcc-plugin.h"
101320 +#include "config.h"
101321 +#include "system.h"
101322 +#include "coretypes.h"
101323 +#include "tree.h"
101324 +#include "tree-pass.h"
101325 +#include "flags.h"
101326 +#include "intl.h"
101327 +#include "toplev.h"
101328 +#include "plugin.h"
101329 +//#include "expr.h" where are you...
101330 +#include "diagnostic.h"
101331 +#include "plugin-version.h"
101332 +#include "tm.h"
101333 +#include "function.h"
101334 +#include "basic-block.h"
101335 +#include "gimple.h"
101336 +#include "rtl.h"
101337 +#include "emit-rtl.h"
101338 +#include "tree-flow.h"
101339 +#include "target.h"
101340 +
101341 +extern void c_register_addr_space (const char *str, addr_space_t as);
101342 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
101343 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
101344 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
101345 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
101346 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
101347 +
101348 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101349 +extern rtx emit_move_insn(rtx x, rtx y);
101350 +
101351 +int plugin_is_GPL_compatible;
101352 +
101353 +static struct plugin_info checker_plugin_info = {
101354 + .version = "201111150100",
101355 + .help = NULL,
101356 +};
101357 +
101358 +#define ADDR_SPACE_KERNEL 0
101359 +#define ADDR_SPACE_FORCE_KERNEL 1
101360 +#define ADDR_SPACE_USER 2
101361 +#define ADDR_SPACE_FORCE_USER 3
101362 +#define ADDR_SPACE_IOMEM 0
101363 +#define ADDR_SPACE_FORCE_IOMEM 0
101364 +#define ADDR_SPACE_PERCPU 0
101365 +#define ADDR_SPACE_FORCE_PERCPU 0
101366 +#define ADDR_SPACE_RCU 0
101367 +#define ADDR_SPACE_FORCE_RCU 0
101368 +
101369 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
101370 +{
101371 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
101372 +}
101373 +
101374 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
101375 +{
101376 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
101377 +}
101378 +
101379 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
101380 +{
101381 + return default_addr_space_valid_pointer_mode(mode, as);
101382 +}
101383 +
101384 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
101385 +{
101386 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
101387 +}
101388 +
101389 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
101390 +{
101391 + return default_addr_space_legitimize_address(x, oldx, mode, as);
101392 +}
101393 +
101394 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
101395 +{
101396 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
101397 + return true;
101398 +
101399 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
101400 + return true;
101401 +
101402 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
101403 + return true;
101404 +
101405 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
101406 + return true;
101407 +
101408 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
101409 + return true;
101410 +
101411 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
101412 + return true;
101413 +
101414 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
101415 + return true;
101416 +
101417 + return subset == superset;
101418 +}
101419 +
101420 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
101421 +{
101422 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
101423 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
101424 +
101425 + return op;
101426 +}
101427 +
101428 +static void register_checker_address_spaces(void *event_data, void *data)
101429 +{
101430 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
101431 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
101432 + c_register_addr_space("__user", ADDR_SPACE_USER);
101433 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
101434 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
101435 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
101436 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
101437 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
101438 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
101439 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
101440 +
101441 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
101442 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
101443 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
101444 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
101445 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
101446 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
101447 + targetm.addr_space.convert = checker_addr_space_convert;
101448 +}
101449 +
101450 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101451 +{
101452 + const char * const plugin_name = plugin_info->base_name;
101453 + const int argc = plugin_info->argc;
101454 + const struct plugin_argument * const argv = plugin_info->argv;
101455 + int i;
101456 +
101457 + if (!plugin_default_version_check(version, &gcc_version)) {
101458 + error(G_("incompatible gcc/plugin versions"));
101459 + return 1;
101460 + }
101461 +
101462 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
101463 +
101464 + for (i = 0; i < argc; ++i)
101465 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101466 +
101467 + if (TARGET_64BIT == 0)
101468 + return 0;
101469 +
101470 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
101471 +
101472 + return 0;
101473 +}
101474 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
101475 new file mode 100644
101476 index 0000000..414fe5e
101477 --- /dev/null
101478 +++ b/tools/gcc/colorize_plugin.c
101479 @@ -0,0 +1,151 @@
101480 +/*
101481 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
101482 + * Licensed under the GPL v2
101483 + *
101484 + * Note: the choice of the license means that the compilation process is
101485 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101486 + * but for the kernel it doesn't matter since it doesn't link against
101487 + * any of the gcc libraries
101488 + *
101489 + * gcc plugin to colorize diagnostic output
101490 + *
101491 + */
101492 +
101493 +#include "gcc-plugin.h"
101494 +#include "config.h"
101495 +#include "system.h"
101496 +#include "coretypes.h"
101497 +#include "tree.h"
101498 +#include "tree-pass.h"
101499 +#include "flags.h"
101500 +#include "intl.h"
101501 +#include "toplev.h"
101502 +#include "plugin.h"
101503 +#include "diagnostic.h"
101504 +#include "plugin-version.h"
101505 +#include "tm.h"
101506 +
101507 +int plugin_is_GPL_compatible;
101508 +
101509 +static struct plugin_info colorize_plugin_info = {
101510 + .version = "201302112000",
101511 + .help = NULL,
101512 +};
101513 +
101514 +#define GREEN "\033[32m\033[2m"
101515 +#define LIGHTGREEN "\033[32m\033[1m"
101516 +#define YELLOW "\033[33m\033[2m"
101517 +#define LIGHTYELLOW "\033[33m\033[1m"
101518 +#define RED "\033[31m\033[2m"
101519 +#define LIGHTRED "\033[31m\033[1m"
101520 +#define BLUE "\033[34m\033[2m"
101521 +#define LIGHTBLUE "\033[34m\033[1m"
101522 +#define BRIGHT "\033[m\033[1m"
101523 +#define NORMAL "\033[m"
101524 +
101525 +static diagnostic_starter_fn old_starter;
101526 +static diagnostic_finalizer_fn old_finalizer;
101527 +
101528 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101529 +{
101530 + const char *color;
101531 + char *newprefix;
101532 +
101533 + switch (diagnostic->kind) {
101534 + case DK_NOTE:
101535 + color = LIGHTBLUE;
101536 + break;
101537 +
101538 + case DK_PEDWARN:
101539 + case DK_WARNING:
101540 + color = LIGHTYELLOW;
101541 + break;
101542 +
101543 + case DK_ERROR:
101544 + case DK_FATAL:
101545 + case DK_ICE:
101546 + case DK_PERMERROR:
101547 + case DK_SORRY:
101548 + color = LIGHTRED;
101549 + break;
101550 +
101551 + default:
101552 + color = NORMAL;
101553 + }
101554 +
101555 + old_starter(context, diagnostic);
101556 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
101557 + return;
101558 + pp_destroy_prefix(context->printer);
101559 + pp_set_prefix(context->printer, newprefix);
101560 +}
101561 +
101562 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101563 +{
101564 + old_finalizer(context, diagnostic);
101565 +}
101566 +
101567 +static void colorize_arm(void)
101568 +{
101569 + old_starter = diagnostic_starter(global_dc);
101570 + old_finalizer = diagnostic_finalizer(global_dc);
101571 +
101572 + diagnostic_starter(global_dc) = start_colorize;
101573 + diagnostic_finalizer(global_dc) = finalize_colorize;
101574 +}
101575 +
101576 +static unsigned int execute_colorize_rearm(void)
101577 +{
101578 + if (diagnostic_starter(global_dc) == start_colorize)
101579 + return 0;
101580 +
101581 + colorize_arm();
101582 + return 0;
101583 +}
101584 +
101585 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
101586 + .pass = {
101587 + .type = SIMPLE_IPA_PASS,
101588 + .name = "colorize_rearm",
101589 +#if BUILDING_GCC_VERSION >= 4008
101590 + .optinfo_flags = OPTGROUP_NONE,
101591 +#endif
101592 + .gate = NULL,
101593 + .execute = execute_colorize_rearm,
101594 + .sub = NULL,
101595 + .next = NULL,
101596 + .static_pass_number = 0,
101597 + .tv_id = TV_NONE,
101598 + .properties_required = 0,
101599 + .properties_provided = 0,
101600 + .properties_destroyed = 0,
101601 + .todo_flags_start = 0,
101602 + .todo_flags_finish = 0
101603 + }
101604 +};
101605 +
101606 +static void colorize_start_unit(void *gcc_data, void *user_data)
101607 +{
101608 + colorize_arm();
101609 +}
101610 +
101611 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101612 +{
101613 + const char * const plugin_name = plugin_info->base_name;
101614 + struct register_pass_info colorize_rearm_pass_info = {
101615 + .pass = &pass_ipa_colorize_rearm.pass,
101616 + .reference_pass_name = "*free_lang_data",
101617 + .ref_pass_instance_number = 1,
101618 + .pos_op = PASS_POS_INSERT_AFTER
101619 + };
101620 +
101621 + if (!plugin_default_version_check(version, &gcc_version)) {
101622 + error(G_("incompatible gcc/plugin versions"));
101623 + return 1;
101624 + }
101625 +
101626 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
101627 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
101628 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
101629 + return 0;
101630 +}
101631 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
101632 new file mode 100644
101633 index 0000000..c17312d
101634 --- /dev/null
101635 +++ b/tools/gcc/constify_plugin.c
101636 @@ -0,0 +1,560 @@
101637 +/*
101638 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
101639 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
101640 + * Licensed under the GPL v2, or (at your option) v3
101641 + *
101642 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
101643 + *
101644 + * Homepage:
101645 + * http://www.grsecurity.net/~ephox/const_plugin/
101646 + *
101647 + * Usage:
101648 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
101649 + * $ gcc -fplugin=constify_plugin.so test.c -O2
101650 + */
101651 +
101652 +#include "gcc-plugin.h"
101653 +#include "config.h"
101654 +#include "system.h"
101655 +#include "coretypes.h"
101656 +#include "tree.h"
101657 +#include "tree-pass.h"
101658 +#include "flags.h"
101659 +#include "intl.h"
101660 +#include "toplev.h"
101661 +#include "plugin.h"
101662 +#include "diagnostic.h"
101663 +#include "plugin-version.h"
101664 +#include "tm.h"
101665 +#include "function.h"
101666 +#include "basic-block.h"
101667 +#include "gimple.h"
101668 +#include "rtl.h"
101669 +#include "emit-rtl.h"
101670 +#include "tree-flow.h"
101671 +#include "target.h"
101672 +#include "langhooks.h"
101673 +
101674 +// should come from c-tree.h if only it were installed for gcc 4.5...
101675 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
101676 +
101677 +// unused type flag in all versions 4.5-4.8
101678 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
101679 +
101680 +int plugin_is_GPL_compatible;
101681 +
101682 +static struct plugin_info const_plugin_info = {
101683 + .version = "201305231310",
101684 + .help = "no-constify\tturn off constification\n",
101685 +};
101686 +
101687 +typedef struct {
101688 + bool has_fptr_field;
101689 + bool has_writable_field;
101690 + bool has_do_const_field;
101691 + bool has_no_const_field;
101692 +} constify_info;
101693 +
101694 +static const_tree get_field_type(const_tree field)
101695 +{
101696 + return strip_array_types(TREE_TYPE(field));
101697 +}
101698 +
101699 +static bool is_fptr(const_tree field)
101700 +{
101701 + const_tree ptr = get_field_type(field);
101702 +
101703 + if (TREE_CODE(ptr) != POINTER_TYPE)
101704 + return false;
101705 +
101706 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
101707 +}
101708 +
101709 +/*
101710 + * determine whether the given structure type meets the requirements for automatic constification,
101711 + * including the constification attributes on nested structure types
101712 + */
101713 +static void constifiable(const_tree node, constify_info *cinfo)
101714 +{
101715 + const_tree field;
101716 +
101717 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101718 +
101719 + // e.g., pointer to structure fields while still constructing the structure type
101720 + if (TYPE_FIELDS(node) == NULL_TREE)
101721 + return;
101722 +
101723 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
101724 + const_tree type = get_field_type(field);
101725 + enum tree_code code = TREE_CODE(type);
101726 +
101727 + if (node == type)
101728 + continue;
101729 +
101730 + if (is_fptr(field))
101731 + cinfo->has_fptr_field = true;
101732 + else if (!TREE_READONLY(field))
101733 + cinfo->has_writable_field = true;
101734 +
101735 + if (code == RECORD_TYPE || code == UNION_TYPE) {
101736 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101737 + cinfo->has_do_const_field = true;
101738 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
101739 + cinfo->has_no_const_field = true;
101740 + else
101741 + constifiable(type, cinfo);
101742 + }
101743 + }
101744 +}
101745 +
101746 +static bool constified(const_tree node)
101747 +{
101748 + constify_info cinfo = {
101749 + .has_fptr_field = false,
101750 + .has_writable_field = false,
101751 + .has_do_const_field = false,
101752 + .has_no_const_field = false
101753 + };
101754 +
101755 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101756 +
101757 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
101758 + gcc_assert(!TYPE_READONLY(node));
101759 + return false;
101760 + }
101761 +
101762 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
101763 + gcc_assert(TYPE_READONLY(node));
101764 + return true;
101765 + }
101766 +
101767 + constifiable(node, &cinfo);
101768 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
101769 + return false;
101770 +
101771 + return TYPE_READONLY(node);
101772 +}
101773 +
101774 +static void deconstify_tree(tree node);
101775 +
101776 +static void deconstify_type(tree type)
101777 +{
101778 + tree field;
101779 +
101780 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
101781 +
101782 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
101783 + const_tree fieldtype = get_field_type(field);
101784 +
101785 + // special case handling of simple ptr-to-same-array-type members
101786 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
101787 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
101788 +
101789 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
101790 + continue;
101791 + if (TREE_TYPE(TREE_TYPE(field)) == type)
101792 + continue;
101793 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
101794 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
101795 + TREE_TYPE(TREE_TYPE(field)) = type;
101796 + }
101797 + continue;
101798 + }
101799 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
101800 + continue;
101801 + if (!constified(fieldtype))
101802 + continue;
101803 +
101804 + deconstify_tree(field);
101805 + TREE_READONLY(field) = 0;
101806 + }
101807 + TYPE_READONLY(type) = 0;
101808 + C_TYPE_FIELDS_READONLY(type) = 0;
101809 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101810 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
101811 +}
101812 +
101813 +static void deconstify_tree(tree node)
101814 +{
101815 + tree old_type, new_type, field;
101816 +
101817 + old_type = TREE_TYPE(node);
101818 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
101819 + node = TREE_TYPE(node) = copy_node(old_type);
101820 + old_type = TREE_TYPE(old_type);
101821 + }
101822 +
101823 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
101824 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
101825 +
101826 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
101827 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
101828 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
101829 + DECL_FIELD_CONTEXT(field) = new_type;
101830 +
101831 + deconstify_type(new_type);
101832 +
101833 + TREE_TYPE(node) = new_type;
101834 +}
101835 +
101836 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101837 +{
101838 + tree type;
101839 + constify_info cinfo = {
101840 + .has_fptr_field = false,
101841 + .has_writable_field = false,
101842 + .has_do_const_field = false,
101843 + .has_no_const_field = false
101844 + };
101845 +
101846 + *no_add_attrs = true;
101847 + if (TREE_CODE(*node) == FUNCTION_DECL) {
101848 + error("%qE attribute does not apply to functions", name);
101849 + return NULL_TREE;
101850 + }
101851 +
101852 + if (TREE_CODE(*node) == PARM_DECL) {
101853 + error("%qE attribute does not apply to function parameters", name);
101854 + return NULL_TREE;
101855 + }
101856 +
101857 + if (TREE_CODE(*node) == VAR_DECL) {
101858 + error("%qE attribute does not apply to variables", name);
101859 + return NULL_TREE;
101860 + }
101861 +
101862 + if (TYPE_P(*node)) {
101863 + *no_add_attrs = false;
101864 + type = *node;
101865 + } else {
101866 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
101867 + type = TREE_TYPE(*node);
101868 + }
101869 +
101870 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
101871 + error("%qE attribute applies to struct and union types only", name);
101872 + return NULL_TREE;
101873 + }
101874 +
101875 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
101876 + error("%qE attribute is already applied to the type", name);
101877 + return NULL_TREE;
101878 + }
101879 +
101880 + if (TYPE_P(*node)) {
101881 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101882 + error("%qE attribute is incompatible with 'do_const'", name);
101883 + return NULL_TREE;
101884 + }
101885 +
101886 + constifiable(type, &cinfo);
101887 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101888 + deconstify_tree(*node);
101889 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
101890 + return NULL_TREE;
101891 + }
101892 +
101893 + error("%qE attribute used on type that is not constified", name);
101894 + return NULL_TREE;
101895 +}
101896 +
101897 +static void constify_type(tree type)
101898 +{
101899 + TYPE_READONLY(type) = 1;
101900 + C_TYPE_FIELDS_READONLY(type) = 1;
101901 + TYPE_CONSTIFY_VISITED(type) = 1;
101902 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
101903 +}
101904 +
101905 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101906 +{
101907 + *no_add_attrs = true;
101908 + if (!TYPE_P(*node)) {
101909 + error("%qE attribute applies to types only", name);
101910 + return NULL_TREE;
101911 + }
101912 +
101913 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101914 + error("%qE attribute applies to struct and union types only", name);
101915 + return NULL_TREE;
101916 + }
101917 +
101918 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101919 + error("%qE attribute is already applied to the type", name);
101920 + return NULL_TREE;
101921 + }
101922 +
101923 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101924 + error("%qE attribute is incompatible with 'no_const'", name);
101925 + return NULL_TREE;
101926 + }
101927 +
101928 + *no_add_attrs = false;
101929 + return NULL_TREE;
101930 +}
101931 +
101932 +static struct attribute_spec no_const_attr = {
101933 + .name = "no_const",
101934 + .min_length = 0,
101935 + .max_length = 0,
101936 + .decl_required = false,
101937 + .type_required = false,
101938 + .function_type_required = false,
101939 + .handler = handle_no_const_attribute,
101940 +#if BUILDING_GCC_VERSION >= 4007
101941 + .affects_type_identity = true
101942 +#endif
101943 +};
101944 +
101945 +static struct attribute_spec do_const_attr = {
101946 + .name = "do_const",
101947 + .min_length = 0,
101948 + .max_length = 0,
101949 + .decl_required = false,
101950 + .type_required = false,
101951 + .function_type_required = false,
101952 + .handler = handle_do_const_attribute,
101953 +#if BUILDING_GCC_VERSION >= 4007
101954 + .affects_type_identity = true
101955 +#endif
101956 +};
101957 +
101958 +static void register_attributes(void *event_data, void *data)
101959 +{
101960 + register_attribute(&no_const_attr);
101961 + register_attribute(&do_const_attr);
101962 +}
101963 +
101964 +static void finish_type(void *event_data, void *data)
101965 +{
101966 + tree type = (tree)event_data;
101967 + constify_info cinfo = {
101968 + .has_fptr_field = false,
101969 + .has_writable_field = false,
101970 + .has_do_const_field = false,
101971 + .has_no_const_field = false
101972 + };
101973 +
101974 + if (type == NULL_TREE || type == error_mark_node)
101975 + return;
101976 +
101977 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101978 + return;
101979 +
101980 + constifiable(type, &cinfo);
101981 +
101982 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
101983 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101984 + return;
101985 + if (cinfo.has_writable_field)
101986 + return;
101987 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
101988 + return;
101989 + }
101990 +
101991 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101992 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101993 + deconstify_type(type);
101994 + TYPE_CONSTIFY_VISITED(type) = 1;
101995 + } else
101996 + error("'no_const' attribute used on type that is not constified");
101997 + return;
101998 + }
101999 +
102000 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102001 + constify_type(type);
102002 + return;
102003 + }
102004 +
102005 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
102006 + constify_type(type);
102007 + return;
102008 + }
102009 +
102010 + deconstify_type(type);
102011 + TYPE_CONSTIFY_VISITED(type) = 1;
102012 +}
102013 +
102014 +static void check_global_variables(void)
102015 +{
102016 + struct varpool_node *node;
102017 +
102018 +#if BUILDING_GCC_VERSION <= 4007
102019 + for (node = varpool_nodes; node; node = node->next) {
102020 + tree var = node->decl;
102021 +#else
102022 + FOR_EACH_VARIABLE(node) {
102023 + tree var = node->symbol.decl;
102024 +#endif
102025 + tree type = TREE_TYPE(var);
102026 +
102027 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102028 + continue;
102029 +
102030 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102031 + continue;
102032 +
102033 + if (!TYPE_CONSTIFY_VISITED(type))
102034 + continue;
102035 +
102036 + if (DECL_EXTERNAL(var))
102037 + continue;
102038 +
102039 + if (DECL_INITIAL(var))
102040 + continue;
102041 +
102042 + // this works around a gcc bug/feature where uninitialized globals
102043 + // are moved into the .bss section regardless of any constification
102044 + DECL_INITIAL(var) = build_constructor(type, NULL);
102045 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
102046 + }
102047 +}
102048 +
102049 +static unsigned int check_local_variables(void)
102050 +{
102051 + unsigned int ret = 0;
102052 + tree var;
102053 +
102054 +#if BUILDING_GCC_VERSION == 4005
102055 + tree vars;
102056 +#else
102057 + unsigned int i;
102058 +#endif
102059 +
102060 +#if BUILDING_GCC_VERSION == 4005
102061 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102062 + var = TREE_VALUE(vars);
102063 +#else
102064 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102065 +#endif
102066 + tree type = TREE_TYPE(var);
102067 +
102068 + gcc_assert(DECL_P(var));
102069 + if (is_global_var(var))
102070 + continue;
102071 +
102072 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102073 + continue;
102074 +
102075 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102076 + continue;
102077 +
102078 + if (!TYPE_CONSTIFY_VISITED(type))
102079 + continue;
102080 +
102081 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
102082 + ret = 1;
102083 + }
102084 + return ret;
102085 +}
102086 +
102087 +static unsigned int check_variables(void)
102088 +{
102089 + check_global_variables();
102090 + return check_local_variables();
102091 +}
102092 +
102093 + unsigned int ret = 0;
102094 +static struct gimple_opt_pass pass_local_variable = {
102095 + {
102096 + .type = GIMPLE_PASS,
102097 + .name = "check_variables",
102098 +#if BUILDING_GCC_VERSION >= 4008
102099 + .optinfo_flags = OPTGROUP_NONE,
102100 +#endif
102101 + .gate = NULL,
102102 + .execute = check_variables,
102103 + .sub = NULL,
102104 + .next = NULL,
102105 + .static_pass_number = 0,
102106 + .tv_id = TV_NONE,
102107 + .properties_required = 0,
102108 + .properties_provided = 0,
102109 + .properties_destroyed = 0,
102110 + .todo_flags_start = 0,
102111 + .todo_flags_finish = 0
102112 + }
102113 +};
102114 +
102115 +static struct {
102116 + const char *name;
102117 + const char *asm_op;
102118 +} sections[] = {
102119 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
102120 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
102121 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
102122 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
102123 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
102124 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
102125 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
102126 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
102127 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
102128 +};
102129 +
102130 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
102131 +
102132 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
102133 +{
102134 + size_t i;
102135 +
102136 + for (i = 0; i < ARRAY_SIZE(sections); i++)
102137 + if (!strcmp(sections[i].name, name))
102138 + return 0;
102139 + return old_section_type_flags(decl, name, reloc);
102140 +}
102141 +
102142 +static void constify_start_unit(void *gcc_data, void *user_data)
102143 +{
102144 +// size_t i;
102145 +
102146 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
102147 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
102148 +// sections[i].section = get_section(sections[i].name, 0, NULL);
102149 +
102150 + old_section_type_flags = targetm.section_type_flags;
102151 + targetm.section_type_flags = constify_section_type_flags;
102152 +}
102153 +
102154 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102155 +{
102156 + const char * const plugin_name = plugin_info->base_name;
102157 + const int argc = plugin_info->argc;
102158 + const struct plugin_argument * const argv = plugin_info->argv;
102159 + int i;
102160 + bool constify = true;
102161 +
102162 + struct register_pass_info local_variable_pass_info = {
102163 + .pass = &pass_local_variable.pass,
102164 + .reference_pass_name = "ssa",
102165 + .ref_pass_instance_number = 1,
102166 + .pos_op = PASS_POS_INSERT_BEFORE
102167 + };
102168 +
102169 + if (!plugin_default_version_check(version, &gcc_version)) {
102170 + error(G_("incompatible gcc/plugin versions"));
102171 + return 1;
102172 + }
102173 +
102174 + for (i = 0; i < argc; ++i) {
102175 + if (!(strcmp(argv[i].key, "no-constify"))) {
102176 + constify = false;
102177 + continue;
102178 + }
102179 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102180 + }
102181 +
102182 + if (strcmp(lang_hooks.name, "GNU C")) {
102183 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102184 + constify = false;
102185 + }
102186 +
102187 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
102188 + if (constify) {
102189 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102190 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
102191 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
102192 + }
102193 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102194 +
102195 + return 0;
102196 +}
102197 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
102198 new file mode 100644
102199 index 0000000..e518932
102200 --- /dev/null
102201 +++ b/tools/gcc/generate_size_overflow_hash.sh
102202 @@ -0,0 +1,94 @@
102203 +#!/bin/bash
102204 +
102205 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
102206 +
102207 +header1="size_overflow_hash.h"
102208 +database="size_overflow_hash.data"
102209 +n=65536
102210 +
102211 +usage() {
102212 +cat <<EOF
102213 +usage: $0 options
102214 +OPTIONS:
102215 + -h|--help help
102216 + -o header file
102217 + -d database file
102218 + -n hash array size
102219 +EOF
102220 + return 0
102221 +}
102222 +
102223 +while true
102224 +do
102225 + case "$1" in
102226 + -h|--help) usage && exit 0;;
102227 + -n) n=$2; shift 2;;
102228 + -o) header1="$2"; shift 2;;
102229 + -d) database="$2"; shift 2;;
102230 + --) shift 1; break ;;
102231 + *) break ;;
102232 + esac
102233 +done
102234 +
102235 +create_defines() {
102236 + for i in `seq 0 31`
102237 + do
102238 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
102239 + done
102240 + echo >> "$header1"
102241 +}
102242 +
102243 +create_structs() {
102244 + rm -f "$header1"
102245 +
102246 + create_defines
102247 +
102248 + cat "$database" | while read data
102249 + do
102250 + data_array=($data)
102251 + struct_hash_name="${data_array[0]}"
102252 + funcn="${data_array[1]}"
102253 + params="${data_array[2]}"
102254 + next="${data_array[4]}"
102255 +
102256 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
102257 +
102258 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
102259 + echo -en "\t.param\t= " >> "$header1"
102260 + line=
102261 + for param_num in ${params//-/ };
102262 + do
102263 + line="${line}PARAM"$param_num"|"
102264 + done
102265 +
102266 + echo -e "${line%?},\n};\n" >> "$header1"
102267 + done
102268 +}
102269 +
102270 +create_headers() {
102271 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
102272 +}
102273 +
102274 +create_array_elements() {
102275 + index=0
102276 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
102277 + do
102278 + data_array=($data)
102279 + i="${data_array[3]}"
102280 + hash="${data_array[0]}"
102281 + while [[ $index -lt $i ]]
102282 + do
102283 + echo -e "\t["$index"]\t= NULL," >> "$header1"
102284 + index=$(($index + 1))
102285 + done
102286 + index=$(($index + 1))
102287 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
102288 + done
102289 + echo '};' >> $header1
102290 +}
102291 +
102292 +create_structs
102293 +create_headers
102294 +create_array_elements
102295 +
102296 +exit 0
102297 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
102298 new file mode 100644
102299 index 0000000..568b360
102300 --- /dev/null
102301 +++ b/tools/gcc/kallocstat_plugin.c
102302 @@ -0,0 +1,170 @@
102303 +/*
102304 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102305 + * Licensed under the GPL v2
102306 + *
102307 + * Note: the choice of the license means that the compilation process is
102308 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102309 + * but for the kernel it doesn't matter since it doesn't link against
102310 + * any of the gcc libraries
102311 + *
102312 + * gcc plugin to find the distribution of k*alloc sizes
102313 + *
102314 + * TODO:
102315 + *
102316 + * BUGS:
102317 + * - none known
102318 + */
102319 +#include "gcc-plugin.h"
102320 +#include "config.h"
102321 +#include "system.h"
102322 +#include "coretypes.h"
102323 +#include "tree.h"
102324 +#include "tree-pass.h"
102325 +#include "flags.h"
102326 +#include "intl.h"
102327 +#include "toplev.h"
102328 +#include "plugin.h"
102329 +//#include "expr.h" where are you...
102330 +#include "diagnostic.h"
102331 +#include "plugin-version.h"
102332 +#include "tm.h"
102333 +#include "function.h"
102334 +#include "basic-block.h"
102335 +#include "gimple.h"
102336 +#include "rtl.h"
102337 +#include "emit-rtl.h"
102338 +
102339 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102340 +
102341 +int plugin_is_GPL_compatible;
102342 +
102343 +static const char * const kalloc_functions[] = {
102344 + "__kmalloc",
102345 + "kmalloc",
102346 + "kmalloc_large",
102347 + "kmalloc_node",
102348 + "kmalloc_order",
102349 + "kmalloc_order_trace",
102350 + "kmalloc_slab",
102351 + "kzalloc",
102352 + "kzalloc_node",
102353 +};
102354 +
102355 +static struct plugin_info kallocstat_plugin_info = {
102356 + .version = "201302112000",
102357 +};
102358 +
102359 +static unsigned int execute_kallocstat(void);
102360 +
102361 +static struct gimple_opt_pass kallocstat_pass = {
102362 + .pass = {
102363 + .type = GIMPLE_PASS,
102364 + .name = "kallocstat",
102365 +#if BUILDING_GCC_VERSION >= 4008
102366 + .optinfo_flags = OPTGROUP_NONE,
102367 +#endif
102368 + .gate = NULL,
102369 + .execute = execute_kallocstat,
102370 + .sub = NULL,
102371 + .next = NULL,
102372 + .static_pass_number = 0,
102373 + .tv_id = TV_NONE,
102374 + .properties_required = 0,
102375 + .properties_provided = 0,
102376 + .properties_destroyed = 0,
102377 + .todo_flags_start = 0,
102378 + .todo_flags_finish = 0
102379 + }
102380 +};
102381 +
102382 +static bool is_kalloc(const char *fnname)
102383 +{
102384 + size_t i;
102385 +
102386 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
102387 + if (!strcmp(fnname, kalloc_functions[i]))
102388 + return true;
102389 + return false;
102390 +}
102391 +
102392 +static unsigned int execute_kallocstat(void)
102393 +{
102394 + basic_block bb;
102395 +
102396 + // 1. loop through BBs and GIMPLE statements
102397 + FOR_EACH_BB(bb) {
102398 + gimple_stmt_iterator gsi;
102399 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102400 + // gimple match:
102401 + tree fndecl, size;
102402 + gimple call_stmt;
102403 + const char *fnname;
102404 +
102405 + // is it a call
102406 + call_stmt = gsi_stmt(gsi);
102407 + if (!is_gimple_call(call_stmt))
102408 + continue;
102409 + fndecl = gimple_call_fndecl(call_stmt);
102410 + if (fndecl == NULL_TREE)
102411 + continue;
102412 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
102413 + continue;
102414 +
102415 + // is it a call to k*alloc
102416 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
102417 + if (!is_kalloc(fnname))
102418 + continue;
102419 +
102420 + // is the size arg the result of a simple const assignment
102421 + size = gimple_call_arg(call_stmt, 0);
102422 + while (true) {
102423 + gimple def_stmt;
102424 + expanded_location xloc;
102425 + size_t size_val;
102426 +
102427 + if (TREE_CODE(size) != SSA_NAME)
102428 + break;
102429 + def_stmt = SSA_NAME_DEF_STMT(size);
102430 + if (!def_stmt || !is_gimple_assign(def_stmt))
102431 + break;
102432 + if (gimple_num_ops(def_stmt) != 2)
102433 + break;
102434 + size = gimple_assign_rhs1(def_stmt);
102435 + if (!TREE_CONSTANT(size))
102436 + continue;
102437 + xloc = expand_location(gimple_location(def_stmt));
102438 + if (!xloc.file)
102439 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102440 + size_val = TREE_INT_CST_LOW(size);
102441 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
102442 + break;
102443 + }
102444 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102445 +//debug_tree(gimple_call_fn(call_stmt));
102446 +//print_node(stderr, "pax", fndecl, 4);
102447 + }
102448 + }
102449 +
102450 + return 0;
102451 +}
102452 +
102453 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102454 +{
102455 + const char * const plugin_name = plugin_info->base_name;
102456 + struct register_pass_info kallocstat_pass_info = {
102457 + .pass = &kallocstat_pass.pass,
102458 + .reference_pass_name = "ssa",
102459 + .ref_pass_instance_number = 1,
102460 + .pos_op = PASS_POS_INSERT_AFTER
102461 + };
102462 +
102463 + if (!plugin_default_version_check(version, &gcc_version)) {
102464 + error(G_("incompatible gcc/plugin versions"));
102465 + return 1;
102466 + }
102467 +
102468 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
102469 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
102470 +
102471 + return 0;
102472 +}
102473 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
102474 new file mode 100644
102475 index 0000000..257529f
102476 --- /dev/null
102477 +++ b/tools/gcc/kernexec_plugin.c
102478 @@ -0,0 +1,471 @@
102479 +/*
102480 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102481 + * Licensed under the GPL v2
102482 + *
102483 + * Note: the choice of the license means that the compilation process is
102484 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102485 + * but for the kernel it doesn't matter since it doesn't link against
102486 + * any of the gcc libraries
102487 + *
102488 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
102489 + *
102490 + * TODO:
102491 + *
102492 + * BUGS:
102493 + * - none known
102494 + */
102495 +#include "gcc-plugin.h"
102496 +#include "config.h"
102497 +#include "system.h"
102498 +#include "coretypes.h"
102499 +#include "tree.h"
102500 +#include "tree-pass.h"
102501 +#include "flags.h"
102502 +#include "intl.h"
102503 +#include "toplev.h"
102504 +#include "plugin.h"
102505 +//#include "expr.h" where are you...
102506 +#include "diagnostic.h"
102507 +#include "plugin-version.h"
102508 +#include "tm.h"
102509 +#include "function.h"
102510 +#include "basic-block.h"
102511 +#include "gimple.h"
102512 +#include "rtl.h"
102513 +#include "emit-rtl.h"
102514 +#include "tree-flow.h"
102515 +
102516 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102517 +extern rtx emit_move_insn(rtx x, rtx y);
102518 +
102519 +#if BUILDING_GCC_VERSION <= 4006
102520 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
102521 +#endif
102522 +
102523 +#if BUILDING_GCC_VERSION >= 4008
102524 +#define TODO_dump_func 0
102525 +#endif
102526 +
102527 +int plugin_is_GPL_compatible;
102528 +
102529 +static struct plugin_info kernexec_plugin_info = {
102530 + .version = "201308230150",
102531 + .help = "method=[bts|or]\tinstrumentation method\n"
102532 +};
102533 +
102534 +static unsigned int execute_kernexec_reload(void);
102535 +static unsigned int execute_kernexec_fptr(void);
102536 +static unsigned int execute_kernexec_retaddr(void);
102537 +static bool kernexec_cmodel_check(void);
102538 +
102539 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
102540 +static void (*kernexec_instrument_retaddr)(rtx);
102541 +
102542 +static struct gimple_opt_pass kernexec_reload_pass = {
102543 + .pass = {
102544 + .type = GIMPLE_PASS,
102545 + .name = "kernexec_reload",
102546 +#if BUILDING_GCC_VERSION >= 4008
102547 + .optinfo_flags = OPTGROUP_NONE,
102548 +#endif
102549 + .gate = kernexec_cmodel_check,
102550 + .execute = execute_kernexec_reload,
102551 + .sub = NULL,
102552 + .next = NULL,
102553 + .static_pass_number = 0,
102554 + .tv_id = TV_NONE,
102555 + .properties_required = 0,
102556 + .properties_provided = 0,
102557 + .properties_destroyed = 0,
102558 + .todo_flags_start = 0,
102559 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102560 + }
102561 +};
102562 +
102563 +static struct gimple_opt_pass kernexec_fptr_pass = {
102564 + .pass = {
102565 + .type = GIMPLE_PASS,
102566 + .name = "kernexec_fptr",
102567 +#if BUILDING_GCC_VERSION >= 4008
102568 + .optinfo_flags = OPTGROUP_NONE,
102569 +#endif
102570 + .gate = kernexec_cmodel_check,
102571 + .execute = execute_kernexec_fptr,
102572 + .sub = NULL,
102573 + .next = NULL,
102574 + .static_pass_number = 0,
102575 + .tv_id = TV_NONE,
102576 + .properties_required = 0,
102577 + .properties_provided = 0,
102578 + .properties_destroyed = 0,
102579 + .todo_flags_start = 0,
102580 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102581 + }
102582 +};
102583 +
102584 +static struct rtl_opt_pass kernexec_retaddr_pass = {
102585 + .pass = {
102586 + .type = RTL_PASS,
102587 + .name = "kernexec_retaddr",
102588 +#if BUILDING_GCC_VERSION >= 4008
102589 + .optinfo_flags = OPTGROUP_NONE,
102590 +#endif
102591 + .gate = kernexec_cmodel_check,
102592 + .execute = execute_kernexec_retaddr,
102593 + .sub = NULL,
102594 + .next = NULL,
102595 + .static_pass_number = 0,
102596 + .tv_id = TV_NONE,
102597 + .properties_required = 0,
102598 + .properties_provided = 0,
102599 + .properties_destroyed = 0,
102600 + .todo_flags_start = 0,
102601 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
102602 + }
102603 +};
102604 +
102605 +static bool kernexec_cmodel_check(void)
102606 +{
102607 + tree section;
102608 +
102609 + if (ix86_cmodel != CM_KERNEL)
102610 + return false;
102611 +
102612 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
102613 + if (!section || !TREE_VALUE(section))
102614 + return true;
102615 +
102616 + section = TREE_VALUE(TREE_VALUE(section));
102617 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
102618 + return true;
102619 +
102620 + return false;
102621 +}
102622 +
102623 +/*
102624 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
102625 + */
102626 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
102627 +{
102628 + gimple asm_movabs_stmt;
102629 +
102630 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
102631 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
102632 + gimple_asm_set_volatile(asm_movabs_stmt, true);
102633 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
102634 + update_stmt(asm_movabs_stmt);
102635 +}
102636 +
102637 +/*
102638 + * find all asm() stmts that clobber r10 and add a reload of r10
102639 + */
102640 +static unsigned int execute_kernexec_reload(void)
102641 +{
102642 + basic_block bb;
102643 +
102644 + // 1. loop through BBs and GIMPLE statements
102645 + FOR_EACH_BB(bb) {
102646 + gimple_stmt_iterator gsi;
102647 +
102648 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102649 + // gimple match: __asm__ ("" : : : "r10");
102650 + gimple asm_stmt;
102651 + size_t nclobbers;
102652 +
102653 + // is it an asm ...
102654 + asm_stmt = gsi_stmt(gsi);
102655 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
102656 + continue;
102657 +
102658 + // ... clobbering r10
102659 + nclobbers = gimple_asm_nclobbers(asm_stmt);
102660 + while (nclobbers--) {
102661 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
102662 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
102663 + continue;
102664 + kernexec_reload_fptr_mask(&gsi);
102665 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
102666 + break;
102667 + }
102668 + }
102669 + }
102670 +
102671 + return 0;
102672 +}
102673 +
102674 +/*
102675 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
102676 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
102677 + */
102678 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
102679 +{
102680 + gimple assign_intptr, assign_new_fptr, call_stmt;
102681 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
102682 +
102683 + call_stmt = gsi_stmt(*gsi);
102684 + old_fptr = gimple_call_fn(call_stmt);
102685 +
102686 + // create temporary unsigned long variable used for bitops and cast fptr to it
102687 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
102688 +#if BUILDING_GCC_VERSION <= 4007
102689 + add_referenced_var(intptr);
102690 +#endif
102691 + intptr = make_ssa_name(intptr, NULL);
102692 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
102693 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102694 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102695 + update_stmt(assign_intptr);
102696 +
102697 + // apply logical or to temporary unsigned long and bitmask
102698 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
102699 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
102700 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
102701 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
102702 + assign_intptr = gimple_build_assign(intptr, orptr);
102703 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102704 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102705 + update_stmt(assign_intptr);
102706 +
102707 + // cast temporary unsigned long back to a temporary fptr variable
102708 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
102709 +#if BUILDING_GCC_VERSION <= 4007
102710 + add_referenced_var(new_fptr);
102711 +#endif
102712 + new_fptr = make_ssa_name(new_fptr, NULL);
102713 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
102714 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
102715 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
102716 + update_stmt(assign_new_fptr);
102717 +
102718 + // replace call stmt fn with the new fptr
102719 + gimple_call_set_fn(call_stmt, new_fptr);
102720 + update_stmt(call_stmt);
102721 +}
102722 +
102723 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
102724 +{
102725 + gimple asm_or_stmt, call_stmt;
102726 + tree old_fptr, new_fptr, input, output;
102727 +#if BUILDING_GCC_VERSION <= 4007
102728 + VEC(tree, gc) *inputs = NULL;
102729 + VEC(tree, gc) *outputs = NULL;
102730 +#else
102731 + vec<tree, va_gc> *inputs = NULL;
102732 + vec<tree, va_gc> *outputs = NULL;
102733 +#endif
102734 +
102735 + call_stmt = gsi_stmt(*gsi);
102736 + old_fptr = gimple_call_fn(call_stmt);
102737 +
102738 + // create temporary fptr variable
102739 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
102740 +#if BUILDING_GCC_VERSION <= 4007
102741 + add_referenced_var(new_fptr);
102742 +#endif
102743 + new_fptr = make_ssa_name(new_fptr, NULL);
102744 +
102745 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
102746 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
102747 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
102748 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
102749 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
102750 +#if BUILDING_GCC_VERSION <= 4007
102751 + VEC_safe_push(tree, gc, inputs, input);
102752 + VEC_safe_push(tree, gc, outputs, output);
102753 +#else
102754 + vec_safe_push(inputs, input);
102755 + vec_safe_push(outputs, output);
102756 +#endif
102757 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
102758 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
102759 + gimple_asm_set_volatile(asm_or_stmt, true);
102760 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
102761 + update_stmt(asm_or_stmt);
102762 +
102763 + // replace call stmt fn with the new fptr
102764 + gimple_call_set_fn(call_stmt, new_fptr);
102765 + update_stmt(call_stmt);
102766 +}
102767 +
102768 +/*
102769 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
102770 + */
102771 +static unsigned int execute_kernexec_fptr(void)
102772 +{
102773 + basic_block bb;
102774 +
102775 + // 1. loop through BBs and GIMPLE statements
102776 + FOR_EACH_BB(bb) {
102777 + gimple_stmt_iterator gsi;
102778 +
102779 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102780 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
102781 + tree fn;
102782 + gimple call_stmt;
102783 +
102784 + // is it a call ...
102785 + call_stmt = gsi_stmt(gsi);
102786 + if (!is_gimple_call(call_stmt))
102787 + continue;
102788 + fn = gimple_call_fn(call_stmt);
102789 + if (TREE_CODE(fn) == ADDR_EXPR)
102790 + continue;
102791 + if (TREE_CODE(fn) != SSA_NAME)
102792 + gcc_unreachable();
102793 +
102794 + // ... through a function pointer
102795 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
102796 + fn = SSA_NAME_VAR(fn);
102797 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
102798 + debug_tree(fn);
102799 + gcc_unreachable();
102800 + }
102801 + }
102802 + fn = TREE_TYPE(fn);
102803 + if (TREE_CODE(fn) != POINTER_TYPE)
102804 + continue;
102805 + fn = TREE_TYPE(fn);
102806 + if (TREE_CODE(fn) != FUNCTION_TYPE)
102807 + continue;
102808 +
102809 + kernexec_instrument_fptr(&gsi);
102810 +
102811 +//debug_tree(gimple_call_fn(call_stmt));
102812 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102813 + }
102814 + }
102815 +
102816 + return 0;
102817 +}
102818 +
102819 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
102820 +static void kernexec_instrument_retaddr_bts(rtx insn)
102821 +{
102822 + rtx btsq;
102823 + rtvec argvec, constraintvec, labelvec;
102824 + int line;
102825 +
102826 + // create asm volatile("btsq $63,(%%rsp)":::)
102827 + argvec = rtvec_alloc(0);
102828 + constraintvec = rtvec_alloc(0);
102829 + labelvec = rtvec_alloc(0);
102830 + line = expand_location(RTL_LOCATION(insn)).line;
102831 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102832 + MEM_VOLATILE_P(btsq) = 1;
102833 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
102834 + emit_insn_before(btsq, insn);
102835 +}
102836 +
102837 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
102838 +static void kernexec_instrument_retaddr_or(rtx insn)
102839 +{
102840 + rtx orq;
102841 + rtvec argvec, constraintvec, labelvec;
102842 + int line;
102843 +
102844 + // create asm volatile("orq %%r10,(%%rsp)":::)
102845 + argvec = rtvec_alloc(0);
102846 + constraintvec = rtvec_alloc(0);
102847 + labelvec = rtvec_alloc(0);
102848 + line = expand_location(RTL_LOCATION(insn)).line;
102849 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102850 + MEM_VOLATILE_P(orq) = 1;
102851 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
102852 + emit_insn_before(orq, insn);
102853 +}
102854 +
102855 +/*
102856 + * find all asm level function returns and forcibly set the highest bit of the return address
102857 + */
102858 +static unsigned int execute_kernexec_retaddr(void)
102859 +{
102860 + rtx insn;
102861 +
102862 + // 1. find function returns
102863 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
102864 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
102865 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
102866 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
102867 + rtx body;
102868 +
102869 + // is it a retn
102870 + if (!JUMP_P(insn))
102871 + continue;
102872 + body = PATTERN(insn);
102873 + if (GET_CODE(body) == PARALLEL)
102874 + body = XVECEXP(body, 0, 0);
102875 + if (!ANY_RETURN_P(body))
102876 + continue;
102877 + kernexec_instrument_retaddr(insn);
102878 + }
102879 +
102880 +// print_simple_rtl(stderr, get_insns());
102881 +// print_rtl(stderr, get_insns());
102882 +
102883 + return 0;
102884 +}
102885 +
102886 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102887 +{
102888 + const char * const plugin_name = plugin_info->base_name;
102889 + const int argc = plugin_info->argc;
102890 + const struct plugin_argument * const argv = plugin_info->argv;
102891 + int i;
102892 + struct register_pass_info kernexec_reload_pass_info = {
102893 + .pass = &kernexec_reload_pass.pass,
102894 + .reference_pass_name = "ssa",
102895 + .ref_pass_instance_number = 1,
102896 + .pos_op = PASS_POS_INSERT_AFTER
102897 + };
102898 + struct register_pass_info kernexec_fptr_pass_info = {
102899 + .pass = &kernexec_fptr_pass.pass,
102900 + .reference_pass_name = "ssa",
102901 + .ref_pass_instance_number = 1,
102902 + .pos_op = PASS_POS_INSERT_AFTER
102903 + };
102904 + struct register_pass_info kernexec_retaddr_pass_info = {
102905 + .pass = &kernexec_retaddr_pass.pass,
102906 + .reference_pass_name = "pro_and_epilogue",
102907 + .ref_pass_instance_number = 1,
102908 + .pos_op = PASS_POS_INSERT_AFTER
102909 + };
102910 +
102911 + if (!plugin_default_version_check(version, &gcc_version)) {
102912 + error(G_("incompatible gcc/plugin versions"));
102913 + return 1;
102914 + }
102915 +
102916 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102917 +
102918 + if (TARGET_64BIT == 0)
102919 + return 0;
102920 +
102921 + for (i = 0; i < argc; ++i) {
102922 + if (!strcmp(argv[i].key, "method")) {
102923 + if (!argv[i].value) {
102924 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102925 + continue;
102926 + }
102927 + if (!strcmp(argv[i].value, "bts")) {
102928 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102929 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102930 + } else if (!strcmp(argv[i].value, "or")) {
102931 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102932 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102933 + fix_register("r10", 1, 1);
102934 + } else
102935 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102936 + continue;
102937 + }
102938 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102939 + }
102940 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102941 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102942 +
102943 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102944 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102945 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102946 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102947 +
102948 + return 0;
102949 +}
102950 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102951 new file mode 100644
102952 index 0000000..2ef6fd9
102953 --- /dev/null
102954 +++ b/tools/gcc/latent_entropy_plugin.c
102955 @@ -0,0 +1,321 @@
102956 +/*
102957 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102958 + * Licensed under the GPL v2
102959 + *
102960 + * Note: the choice of the license means that the compilation process is
102961 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102962 + * but for the kernel it doesn't matter since it doesn't link against
102963 + * any of the gcc libraries
102964 + *
102965 + * gcc plugin to help generate a little bit of entropy from program state,
102966 + * used during boot in the kernel
102967 + *
102968 + * TODO:
102969 + * - add ipa pass to identify not explicitly marked candidate functions
102970 + * - mix in more program state (function arguments/return values, loop variables, etc)
102971 + * - more instrumentation control via attribute parameters
102972 + *
102973 + * BUGS:
102974 + * - LTO needs -flto-partition=none for now
102975 + */
102976 +#include "gcc-plugin.h"
102977 +#include "config.h"
102978 +#include "system.h"
102979 +#include "coretypes.h"
102980 +#include "tree.h"
102981 +#include "tree-pass.h"
102982 +#include "flags.h"
102983 +#include "intl.h"
102984 +#include "toplev.h"
102985 +#include "plugin.h"
102986 +//#include "expr.h" where are you...
102987 +#include "diagnostic.h"
102988 +#include "plugin-version.h"
102989 +#include "tm.h"
102990 +#include "function.h"
102991 +#include "basic-block.h"
102992 +#include "gimple.h"
102993 +#include "rtl.h"
102994 +#include "emit-rtl.h"
102995 +#include "tree-flow.h"
102996 +#include "langhooks.h"
102997 +
102998 +#if BUILDING_GCC_VERSION >= 4008
102999 +#define TODO_dump_func 0
103000 +#endif
103001 +
103002 +int plugin_is_GPL_compatible;
103003 +
103004 +static tree latent_entropy_decl;
103005 +
103006 +static struct plugin_info latent_entropy_plugin_info = {
103007 + .version = "201308230230",
103008 + .help = NULL
103009 +};
103010 +
103011 +static unsigned int execute_latent_entropy(void);
103012 +static bool gate_latent_entropy(void);
103013 +
103014 +static struct gimple_opt_pass latent_entropy_pass = {
103015 + .pass = {
103016 + .type = GIMPLE_PASS,
103017 + .name = "latent_entropy",
103018 +#if BUILDING_GCC_VERSION >= 4008
103019 + .optinfo_flags = OPTGROUP_NONE,
103020 +#endif
103021 + .gate = gate_latent_entropy,
103022 + .execute = execute_latent_entropy,
103023 + .sub = NULL,
103024 + .next = NULL,
103025 + .static_pass_number = 0,
103026 + .tv_id = TV_NONE,
103027 + .properties_required = PROP_gimple_leh | PROP_cfg,
103028 + .properties_provided = 0,
103029 + .properties_destroyed = 0,
103030 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103031 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103032 + }
103033 +};
103034 +
103035 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103036 +{
103037 + if (TREE_CODE(*node) != FUNCTION_DECL) {
103038 + *no_add_attrs = true;
103039 + error("%qE attribute only applies to functions", name);
103040 + }
103041 + return NULL_TREE;
103042 +}
103043 +
103044 +static struct attribute_spec latent_entropy_attr = {
103045 + .name = "latent_entropy",
103046 + .min_length = 0,
103047 + .max_length = 0,
103048 + .decl_required = true,
103049 + .type_required = false,
103050 + .function_type_required = false,
103051 + .handler = handle_latent_entropy_attribute,
103052 +#if BUILDING_GCC_VERSION >= 4007
103053 + .affects_type_identity = false
103054 +#endif
103055 +};
103056 +
103057 +static void register_attributes(void *event_data, void *data)
103058 +{
103059 + register_attribute(&latent_entropy_attr);
103060 +}
103061 +
103062 +static bool gate_latent_entropy(void)
103063 +{
103064 + tree latent_entropy_attr;
103065 +
103066 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
103067 + return latent_entropy_attr != NULL_TREE;
103068 +}
103069 +
103070 +static unsigned HOST_WIDE_INT seed;
103071 +static unsigned HOST_WIDE_INT get_random_const(void)
103072 +{
103073 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
103074 + return seed;
103075 +}
103076 +
103077 +static enum tree_code get_op(tree *rhs)
103078 +{
103079 + static enum tree_code op;
103080 + unsigned HOST_WIDE_INT random_const;
103081 +
103082 + random_const = get_random_const();
103083 +
103084 + switch (op) {
103085 + case BIT_XOR_EXPR:
103086 + op = PLUS_EXPR;
103087 + break;
103088 +
103089 + case PLUS_EXPR:
103090 + if (rhs) {
103091 + op = LROTATE_EXPR;
103092 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
103093 + break;
103094 + }
103095 +
103096 + case LROTATE_EXPR:
103097 + default:
103098 + op = BIT_XOR_EXPR;
103099 + break;
103100 + }
103101 + if (rhs)
103102 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
103103 + return op;
103104 +}
103105 +
103106 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
103107 +{
103108 + gimple_stmt_iterator gsi;
103109 + gimple assign;
103110 + tree addxorrol, rhs;
103111 + enum tree_code op;
103112 +
103113 + op = get_op(&rhs);
103114 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
103115 + assign = gimple_build_assign(local_entropy, addxorrol);
103116 + gsi = gsi_after_labels(bb);
103117 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
103118 + update_stmt(assign);
103119 +//debug_bb(bb);
103120 +}
103121 +
103122 +static void perturb_latent_entropy(basic_block bb, tree rhs)
103123 +{
103124 + gimple_stmt_iterator gsi;
103125 + gimple assign;
103126 + tree addxorrol, temp;
103127 +
103128 + // 1. create temporary copy of latent_entropy
103129 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
103130 +#if BUILDING_GCC_VERSION <= 4007
103131 + add_referenced_var(temp);
103132 +#endif
103133 +
103134 + // 2. read...
103135 + temp = make_ssa_name(temp, NULL);
103136 + assign = gimple_build_assign(temp, latent_entropy_decl);
103137 + SSA_NAME_DEF_STMT(temp) = assign;
103138 +#if BUILDING_GCC_VERSION <= 4007
103139 + add_referenced_var(latent_entropy_decl);
103140 +#endif
103141 + gsi = gsi_after_labels(bb);
103142 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103143 + update_stmt(assign);
103144 +
103145 + // 3. ...modify...
103146 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
103147 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
103148 + assign = gimple_build_assign(temp, addxorrol);
103149 + SSA_NAME_DEF_STMT(temp) = assign;
103150 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103151 + update_stmt(assign);
103152 +
103153 + // 4. ...write latent_entropy
103154 + assign = gimple_build_assign(latent_entropy_decl, temp);
103155 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103156 + update_stmt(assign);
103157 +}
103158 +
103159 +static unsigned int execute_latent_entropy(void)
103160 +{
103161 + basic_block bb;
103162 + gimple assign;
103163 + gimple_stmt_iterator gsi;
103164 + tree local_entropy;
103165 +
103166 + if (!latent_entropy_decl) {
103167 + struct varpool_node *node;
103168 +
103169 +#if BUILDING_GCC_VERSION <= 4007
103170 + for (node = varpool_nodes; node; node = node->next) {
103171 + tree var = node->decl;
103172 +#else
103173 + FOR_EACH_VARIABLE(node) {
103174 + tree var = node->symbol.decl;
103175 +#endif
103176 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
103177 + continue;
103178 + latent_entropy_decl = var;
103179 +// debug_tree(var);
103180 + break;
103181 + }
103182 + if (!latent_entropy_decl) {
103183 +// debug_tree(current_function_decl);
103184 + return 0;
103185 + }
103186 + }
103187 +
103188 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
103189 +
103190 + // 1. create local entropy variable
103191 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
103192 +#if BUILDING_GCC_VERSION <= 4007
103193 + add_referenced_var(local_entropy);
103194 + mark_sym_for_renaming(local_entropy);
103195 +#endif
103196 +
103197 + // 2. initialize local entropy variable
103198 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103199 + if (dom_info_available_p(CDI_DOMINATORS))
103200 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103201 + gsi = gsi_start_bb(bb);
103202 +
103203 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
103204 +// gimple_set_location(assign, loc);
103205 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103206 + update_stmt(assign);
103207 +//debug_bb(bb);
103208 + bb = bb->next_bb;
103209 +
103210 + // 3. instrument each BB with an operation on the local entropy variable
103211 + while (bb != EXIT_BLOCK_PTR) {
103212 + perturb_local_entropy(bb, local_entropy);
103213 +//debug_bb(bb);
103214 + bb = bb->next_bb;
103215 + };
103216 +
103217 + // 4. mix local entropy into the global entropy variable
103218 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
103219 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
103220 + return 0;
103221 +}
103222 +
103223 +static void start_unit_callback(void *gcc_data, void *user_data)
103224 +{
103225 + tree latent_entropy_type;
103226 +
103227 +#if BUILDING_GCC_VERSION >= 4007
103228 + seed = get_random_seed(false);
103229 +#else
103230 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
103231 + seed *= seed;
103232 +#endif
103233 +
103234 + if (in_lto_p)
103235 + return;
103236 +
103237 + // extern volatile u64 latent_entropy
103238 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
103239 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
103240 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
103241 +
103242 + TREE_STATIC(latent_entropy_decl) = 1;
103243 + TREE_PUBLIC(latent_entropy_decl) = 1;
103244 + TREE_USED(latent_entropy_decl) = 1;
103245 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
103246 + DECL_EXTERNAL(latent_entropy_decl) = 1;
103247 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
103248 + DECL_INITIAL(latent_entropy_decl) = NULL;
103249 + lang_hooks.decls.pushdecl(latent_entropy_decl);
103250 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
103251 +// varpool_finalize_decl(latent_entropy_decl);
103252 +// varpool_mark_needed_node(latent_entropy_decl);
103253 +}
103254 +
103255 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103256 +{
103257 + const char * const plugin_name = plugin_info->base_name;
103258 + struct register_pass_info latent_entropy_pass_info = {
103259 + .pass = &latent_entropy_pass.pass,
103260 + .reference_pass_name = "optimized",
103261 + .ref_pass_instance_number = 1,
103262 + .pos_op = PASS_POS_INSERT_BEFORE
103263 + };
103264 +
103265 + if (!plugin_default_version_check(version, &gcc_version)) {
103266 + error(G_("incompatible gcc/plugin versions"));
103267 + return 1;
103268 + }
103269 +
103270 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
103271 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103272 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
103273 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103274 +
103275 + return 0;
103276 +}
103277 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
103278 new file mode 100644
103279 index 0000000..b04803b
103280 --- /dev/null
103281 +++ b/tools/gcc/size_overflow_hash.data
103282 @@ -0,0 +1,6350 @@
103283 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
103284 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
103285 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
103286 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
103287 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
103288 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
103289 +padzero_55 padzero 1 55 &sel_read_policyvers_55
103290 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
103291 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
103292 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
103293 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
103294 +load_msg_95 load_msg 2 95 NULL
103295 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
103296 +init_q_132 init_q 4 132 NULL
103297 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
103298 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
103299 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
103300 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
103301 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
103302 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
103303 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
103304 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
103305 +br_port_info_size_268 br_port_info_size 0 268 NULL
103306 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
103307 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
103308 +SYSC_connect_304 SYSC_connect 3 304 NULL
103309 +syslog_print_307 syslog_print 2 307 NULL
103310 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
103311 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
103312 +next_node_allowed_318 next_node_allowed 1 318 NULL
103313 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
103314 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
103315 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
103316 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
103317 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
103318 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
103319 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
103320 +pidlist_resize_496 pidlist_resize 2 496 NULL
103321 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
103322 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
103323 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
103324 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
103325 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
103326 +dle_count_543 dle_count 0 543 NULL
103327 +devres_alloc_551 devres_alloc 2 551 NULL
103328 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
103329 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
103330 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
103331 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
103332 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
103333 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
103334 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
103335 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
103336 +isp1760_register_628 isp1760_register 1-2 628 NULL
103337 +clone_split_bio_633 clone_split_bio 6 633 NULL
103338 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
103339 +remap_to_cache_640 remap_to_cache 3 640 NULL
103340 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
103341 +unlink_queued_645 unlink_queued 3-4 645 NULL
103342 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
103343 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
103344 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
103345 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
103346 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
103347 +disk_max_parts_719 disk_max_parts 0 719 NULL
103348 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
103349 +dvb_video_write_754 dvb_video_write 3 754 NULL
103350 +if_writecmd_815 if_writecmd 2 815 NULL
103351 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
103352 +read_fifo_826 read_fifo 3 826 NULL
103353 +um_idi_read_850 um_idi_read 3 850 NULL
103354 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
103355 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
103356 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
103357 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
103358 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
103359 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
103360 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
103361 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
103362 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
103363 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
103364 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
103365 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
103366 +_do_truncate_1019 _do_truncate 2 1019 NULL
103367 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
103368 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
103369 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
103370 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
103371 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
103372 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
103373 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
103374 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
103375 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
103376 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
103377 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
103378 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
103379 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
103380 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
103381 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
103382 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
103383 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
103384 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
103385 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
103386 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
103387 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
103388 +nested_get_page_1252 nested_get_page 2 1252 NULL
103389 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
103390 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
103391 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
103392 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
103393 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
103394 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
103395 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
103396 +ffs_1322 ffs 0 1322 NULL
103397 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
103398 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
103399 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
103400 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
103401 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
103402 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
103403 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
103404 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
103405 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
103406 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
103407 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
103408 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
103409 +zone_page_state_1393 zone_page_state 0 1393 NULL
103410 +file_read_actor_1401 file_read_actor 4 1401 NULL
103411 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
103412 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
103413 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
103414 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
103415 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
103416 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
103417 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
103418 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
103419 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
103420 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
103421 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
103422 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
103423 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
103424 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
103425 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
103426 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
103427 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
103428 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
103429 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
103430 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
103431 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
103432 +rmap_add_1677 rmap_add 3 1677 NULL
103433 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
103434 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
103435 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
103436 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
103437 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
103438 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
103439 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
103440 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
103441 +cosa_write_1774 cosa_write 3 1774 NULL
103442 +update_macheader_1775 update_macheader 7 1775 NULL
103443 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
103444 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
103445 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
103446 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
103447 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
103448 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
103449 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
103450 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
103451 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
103452 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
103453 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
103454 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
103455 +read_swap_header_1957 read_swap_header 0 1957 NULL
103456 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
103457 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
103458 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
103459 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
103460 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
103461 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
103462 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
103463 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
103464 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
103465 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
103466 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
103467 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
103468 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
103469 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
103470 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
103471 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
103472 +audit_expand_2098 audit_expand 2 2098 NULL
103473 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
103474 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
103475 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
103476 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
103477 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
103478 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
103479 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
103480 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
103481 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
103482 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
103483 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
103484 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
103485 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
103486 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
103487 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
103488 +vhci_write_2224 vhci_write 3 2224 NULL
103489 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
103490 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
103491 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
103492 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
103493 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
103494 +do_update_counters_2259 do_update_counters 4 2259 NULL
103495 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
103496 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
103497 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
103498 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
103499 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
103500 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
103501 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
103502 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
103503 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
103504 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
103505 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
103506 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
103507 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
103508 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
103509 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
103510 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
103511 +raid1_size_2419 raid1_size 0-2 2419 NULL
103512 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
103513 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
103514 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
103515 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
103516 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
103517 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
103518 +update_pmkid_2481 update_pmkid 4 2481 NULL
103519 +wiphy_new_2482 wiphy_new 2 2482 NULL
103520 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
103521 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
103522 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
103523 +dm_write_2513 dm_write 3 2513 NULL
103524 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
103525 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
103526 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
103527 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
103528 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
103529 +slot_bytes_2609 slot_bytes 0 2609 NULL
103530 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
103531 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
103532 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
103533 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
103534 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
103535 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
103536 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
103537 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
103538 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
103539 +__next_cpu_2782 __next_cpu 1 2782 NULL
103540 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
103541 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
103542 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
103543 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
103544 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
103545 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
103546 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
103547 +mq_map_2871 mq_map 2 2871 NULL
103548 +nla_padlen_2883 nla_padlen 1 2883 NULL
103549 +cmm_write_2896 cmm_write 3 2896 NULL
103550 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
103551 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
103552 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
103553 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
103554 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
103555 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
103556 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
103557 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
103558 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
103559 +depth_write_3021 depth_write 3 3021 NULL
103560 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
103561 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
103562 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
103563 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
103564 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
103565 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
103566 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
103567 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
103568 +free_coherent_3082 free_coherent 4-2 3082 NULL
103569 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
103570 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
103571 +rb_alloc_3102 rb_alloc 1 3102 NULL
103572 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
103573 +print_time_3132 print_time 0 3132 NULL
103574 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
103575 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
103576 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
103577 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
103578 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
103579 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
103580 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
103581 +alloc_context_3194 alloc_context 1 3194 NULL
103582 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
103583 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
103584 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
103585 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
103586 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
103587 +key_key_read_3241 key_key_read 3 3241 NULL
103588 +number_3243 number 0 3243 NULL
103589 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
103590 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
103591 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
103592 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
103593 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
103594 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
103595 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
103596 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
103597 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
103598 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
103599 +scnprintf_3360 scnprintf 0-2 3360 NULL
103600 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
103601 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
103602 +send_stream_3397 send_stream 4 3397 NULL
103603 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
103604 +msix_map_region_3411 msix_map_region 3 3411 NULL
103605 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
103606 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
103607 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
103608 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
103609 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
103610 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
103611 +map_single_3449 map_single 0-2 3449 NULL
103612 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
103613 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
103614 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
103615 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
103616 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
103617 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
103618 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
103619 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
103620 +SyS_readv_3539 SyS_readv 3 3539 NULL
103621 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
103622 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
103623 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
103624 +evtchn_read_3569 evtchn_read 3 3569 NULL
103625 +vc_resize_3585 vc_resize 2-3 3585 NULL
103626 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
103627 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
103628 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
103629 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
103630 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
103631 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
103632 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
103633 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
103634 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
103635 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
103636 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
103637 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
103638 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
103639 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
103640 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
103641 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
103642 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
103643 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
103644 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
103645 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
103646 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
103647 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
103648 +get_fd_set_3866 get_fd_set 1 3866 NULL
103649 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
103650 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
103651 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
103652 +nvram_write_3894 nvram_write 3 3894 NULL
103653 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
103654 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
103655 +vcs_write_3910 vcs_write 3 3910 NULL
103656 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
103657 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
103658 +do_add_counters_3992 do_add_counters 3 3992 NULL
103659 +userspace_status_4004 userspace_status 4 4004 NULL
103660 +mei_write_4005 mei_write 3 4005 NULL nohasharray
103661 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
103662 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
103663 +mm_populate_4016 mm_populate 1 4016 NULL
103664 +blk_end_request_4024 blk_end_request 3 4024 NULL
103665 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
103666 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
103667 +read_file_queues_4078 read_file_queues 3 4078 NULL
103668 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
103669 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
103670 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
103671 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
103672 +tm6000_read_4151 tm6000_read 3 4151 NULL
103673 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
103674 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
103675 +get_alua_req_4166 get_alua_req 3 4166 NULL
103676 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
103677 +read_file_bool_4180 read_file_bool 3 4180 NULL
103678 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
103679 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
103680 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
103681 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
103682 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
103683 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
103684 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
103685 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
103686 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
103687 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
103688 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
103689 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
103690 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
103691 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
103692 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
103693 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
103694 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
103695 +memparse_4444 memparse 0 4444 NULL
103696 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
103697 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
103698 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
103699 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
103700 +set_link_security_4502 set_link_security 4 4502 NULL
103701 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
103702 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
103703 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
103704 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
103705 +tty_register_device_4544 tty_register_device 2 4544 NULL
103706 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
103707 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
103708 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
103709 +bch_alloc_4593 bch_alloc 1 4593 NULL
103710 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
103711 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
103712 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
103713 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
103714 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
103715 +kone_receive_4690 kone_receive 4 4690 NULL
103716 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
103717 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
103718 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
103719 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
103720 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
103721 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
103722 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
103723 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
103724 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
103725 +create_subvol_4791 create_subvol 4 4791 NULL
103726 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
103727 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
103728 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
103729 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
103730 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
103731 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
103732 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
103733 +sys_ipc_4889 sys_ipc 3 4889 NULL
103734 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
103735 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
103736 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
103737 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
103738 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
103739 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
103740 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
103741 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
103742 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
103743 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
103744 +do_mincore_5018 do_mincore 0-1 5018 NULL
103745 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
103746 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
103747 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
103748 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
103749 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
103750 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
103751 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
103752 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
103753 +sound_write_5102 sound_write 3 5102 NULL
103754 +clear_dirty_5105 clear_dirty 3 5105 NULL
103755 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
103756 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
103757 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
103758 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
103759 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
103760 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
103761 +skb_network_header_5203 skb_network_header 0 5203 NULL
103762 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
103763 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
103764 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
103765 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
103766 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
103767 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
103768 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
103769 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
103770 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
103771 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
103772 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
103773 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
103774 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
103775 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
103776 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
103777 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
103778 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
103779 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
103780 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
103781 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
103782 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
103783 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
103784 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
103785 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
103786 +tty_write_5494 tty_write 3 5494 NULL
103787 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
103788 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
103789 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
103790 +spidev_message_5518 spidev_message 3 5518 NULL
103791 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
103792 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
103793 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
103794 +le_readq_5557 le_readq 0 5557 NULL
103795 +inw_5558 inw 0 5558 NULL
103796 +fir16_create_5574 fir16_create 3 5574 NULL
103797 +bioset_create_5580 bioset_create 1 5580 NULL
103798 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
103799 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
103800 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103801 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103802 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103803 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103804 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103805 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
103806 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
103807 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103808 +get_arg_5694 get_arg 3 5694 NULL
103809 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103810 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103811 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
103812 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103813 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
103814 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
103815 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
103816 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
103817 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103818 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103819 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103820 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103821 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
103822 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103823 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
103824 +setup_req_5848 setup_req 3 5848 NULL
103825 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103826 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
103827 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
103828 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103829 +port_show_regs_5904 port_show_regs 3 5904 NULL
103830 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103831 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103832 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
103833 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
103834 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103835 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103836 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103837 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
103838 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103839 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103840 +native_pte_val_5978 native_pte_val 0 5978 NULL
103841 +SyS_semop_5980 SyS_semop 3 5980 NULL
103842 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
103843 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
103844 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103845 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103846 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103847 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103848 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103849 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
103850 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103851 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103852 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103853 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103854 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103855 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103856 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103857 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103858 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103859 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103860 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103861 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103862 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103863 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103864 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
103865 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103866 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103867 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103868 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
103869 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
103870 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
103871 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103872 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
103873 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
103874 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
103875 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
103876 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
103877 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
103878 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
103879 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
103880 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
103881 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
103882 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
103883 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
103884 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
103885 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
103886 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
103887 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
103888 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
103889 +mei_read_6507 mei_read 3 6507 NULL
103890 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
103891 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
103892 +wdm_read_6549 wdm_read 3 6549 NULL
103893 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
103894 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
103895 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
103896 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
103897 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
103898 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
103899 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
103900 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
103901 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
103902 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
103903 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
103904 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
103905 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
103906 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
103907 +mpeg_read_6708 mpeg_read 3 6708 NULL
103908 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
103909 +video_proc_write_6724 video_proc_write 3 6724 NULL
103910 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
103911 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
103912 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
103913 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
103914 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
103915 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
103916 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
103917 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
103918 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
103919 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
103920 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
103921 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
103922 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
103923 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
103924 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
103925 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
103926 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
103927 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
103928 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
103929 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
103930 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
103931 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
103932 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
103933 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
103934 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
103935 +request_key_async_6990 request_key_async 4 6990 NULL
103936 +tpl_write_6998 tpl_write 3 6998 NULL
103937 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
103938 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
103939 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
103940 +wimax_msg_7030 wimax_msg 4 7030 NULL
103941 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
103942 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
103943 +event_enable_read_7074 event_enable_read 3 7074 NULL
103944 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
103945 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
103946 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103947 +check_header_7108 check_header 0 7108 NULL
103948 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103949 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103950 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
103951 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
103952 +get_param_h_7247 get_param_h 0 7247 NULL
103953 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
103954 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103955 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
103956 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103957 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
103958 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103959 +mgmt_control_7349 mgmt_control 3 7349 NULL
103960 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
103961 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103962 +hweight_long_7388 hweight_long 0-1 7388 NULL
103963 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
103964 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103965 +readb_7401 readb 0 7401 NULL
103966 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103967 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103968 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103969 +numa_emulation_7466 numa_emulation 2 7466 NULL
103970 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
103971 +garp_request_join_7471 garp_request_join 4 7471 NULL
103972 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
103973 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103974 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103975 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103976 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
103977 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103978 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103979 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
103980 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
103981 +groups_alloc_7614 groups_alloc 1 7614 NULL
103982 +sg_virt_7616 sg_virt 0 7616 NULL
103983 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
103984 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
103985 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103986 +dev_write_7708 dev_write 3 7708 NULL
103987 +unmap_region_7709 unmap_region 1 7709 NULL
103988 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
103989 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
103990 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103991 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
103992 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103993 +ioread32be_7773 ioread32be 0 7773 NULL
103994 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103995 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103996 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
103997 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
103998 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103999 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
104000 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
104001 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
104002 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
104003 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
104004 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
104005 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
104006 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
104007 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
104008 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
104009 +sys_mbind_7990 sys_mbind 5 7990 NULL
104010 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
104011 +vcs_read_8017 vcs_read 3 8017 NULL
104012 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
104013 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
104014 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
104015 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
104016 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
104017 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
104018 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
104019 +venus_lookup_8121 venus_lookup 4 8121 NULL
104020 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
104021 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
104022 +ore_truncate_8181 ore_truncate 3 8181 NULL
104023 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
104024 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
104025 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
104026 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
104027 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
104028 +play_iframe_8219 play_iframe 3 8219 NULL
104029 +create_log_8225 create_log 2 8225 NULL nohasharray
104030 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
104031 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
104032 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
104033 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
104034 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
104035 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
104036 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
104037 +init_cdev_8274 init_cdev 1 8274 NULL
104038 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
104039 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
104040 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
104041 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
104042 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
104043 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
104044 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
104045 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
104046 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
104047 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
104048 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
104049 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
104050 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
104051 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
104052 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
104053 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
104054 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
104055 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
104056 +dev_config_8506 dev_config 3 8506 NULL
104057 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
104058 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
104059 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
104060 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
104061 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
104062 +user_on_off_8552 user_on_off 2 8552 NULL
104063 +profile_remove_8556 profile_remove 3 8556 NULL
104064 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
104065 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
104066 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
104067 +tower_write_8580 tower_write 3 8580 NULL
104068 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
104069 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
104070 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
104071 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
104072 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
104073 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
104074 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
104075 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
104076 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
104077 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
104078 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
104079 +arcfb_write_8702 arcfb_write 3 8702 NULL
104080 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
104081 +init_header_8703 init_header 0 8703 &i_size_read_8703
104082 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
104083 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
104084 +f_dupfd_8730 f_dupfd 1 8730 NULL
104085 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
104086 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
104087 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
104088 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
104089 +sys_prctl_8766 sys_prctl 4 8766 NULL
104090 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
104091 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
104092 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
104093 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
104094 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
104095 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
104096 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
104097 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
104098 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
104099 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
104100 +clear_bitset_8840 clear_bitset 2 8840 NULL
104101 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
104102 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
104103 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
104104 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
104105 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
104106 +layout_commit_8926 layout_commit 3 8926 NULL
104107 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
104108 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
104109 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
104110 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
104111 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
104112 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
104113 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
104114 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
104115 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
104116 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
104117 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
104118 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
104119 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
104120 +nla_put_9042 nla_put 3 9042 NULL
104121 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
104122 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
104123 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
104124 +string_9080 string 0 9080 NULL
104125 +create_queues_9088 create_queues 2-3 9088 NULL
104126 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
104127 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
104128 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
104129 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
104130 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
104131 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
104132 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
104133 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
104134 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
104135 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
104136 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
104137 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
104138 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
104139 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
104140 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
104141 +get_pfn_9207 get_pfn 1 9207 NULL
104142 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
104143 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
104144 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
104145 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
104146 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
104147 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
104148 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
104149 +flakey_status_9274 flakey_status 5 9274 NULL
104150 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
104151 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
104152 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
104153 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
104154 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
104155 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
104156 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
104157 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
104158 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
104159 +read_9397 read 3 9397 NULL
104160 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
104161 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
104162 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
104163 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
104164 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
104165 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
104166 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
104167 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
104168 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
104169 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
104170 +lp_write_9511 lp_write 3 9511 NULL
104171 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
104172 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
104173 +read_file_dma_9530 read_file_dma 3 9530 NULL
104174 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
104175 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
104176 +fw_node_create_9559 fw_node_create 2 9559 NULL
104177 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
104178 +kobj_map_9566 kobj_map 2-3 9566 NULL
104179 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
104180 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
104181 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
104182 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
104183 +do_sync_9604 do_sync 1 9604 NULL
104184 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
104185 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
104186 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
104187 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
104188 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
104189 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
104190 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
104191 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
104192 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
104193 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
104194 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
104195 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
104196 +is_hole_9694 is_hole 2 9694 NULL nohasharray
104197 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
104198 +fnb_9703 fnb 2-3 9703 NULL
104199 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
104200 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
104201 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
104202 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
104203 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
104204 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
104205 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
104206 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
104207 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
104208 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
104209 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
104210 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
104211 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
104212 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
104213 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
104214 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
104215 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
104216 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
104217 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
104218 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
104219 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
104220 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
104221 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
104222 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
104223 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
104224 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
104225 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
104226 +read_file_misc_9948 read_file_misc 3 9948 NULL
104227 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
104228 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
104229 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
104230 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
104231 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
104232 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
104233 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
104234 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
104235 +handle_request_10024 handle_request 9 10024 NULL
104236 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
104237 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
104238 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
104239 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
104240 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
104241 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
104242 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
104243 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
104244 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
104245 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
104246 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
104247 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
104248 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
104249 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
104250 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
104251 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
104252 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
104253 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
104254 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
104255 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
104256 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
104257 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
104258 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
104259 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
104260 +read_emulate_10310 read_emulate 2-4 10310 NULL
104261 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
104262 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
104263 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
104264 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
104265 +get_dump_page_10338 get_dump_page 1 10338 NULL
104266 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
104267 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
104268 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
104269 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
104270 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
104271 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
104272 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
104273 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
104274 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
104275 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
104276 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
104277 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
104278 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
104279 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
104280 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
104281 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
104282 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
104283 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
104284 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
104285 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
104286 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
104287 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
104288 +otp_read_10594 otp_read 2-4-5 10594 NULL
104289 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
104290 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
104291 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
104292 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
104293 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
104294 +parport_write_10669 parport_write 0 10669 NULL
104295 +inl_10708 inl 0 10708 NULL nohasharray
104296 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
104297 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
104298 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
104299 +spi_sync_10731 spi_sync 0 10731 NULL
104300 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
104301 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
104302 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
104303 +sys_syslog_10746 sys_syslog 3 10746 NULL
104304 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
104305 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
104306 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
104307 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
104308 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
104309 +sys_bind_10799 sys_bind 3 10799 NULL
104310 +compat_put_int_10828 compat_put_int 1 10828 NULL
104311 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
104312 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
104313 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
104314 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
104315 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
104316 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
104317 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
104318 +get_scq_10897 get_scq 2 10897 NULL
104319 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
104320 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
104321 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
104322 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
104323 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
104324 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
104325 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
104326 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
104327 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
104328 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
104329 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
104330 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
104331 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
104332 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
104333 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
104334 +count_argc_11083 count_argc 0 11083 NULL
104335 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
104336 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
104337 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
104338 +page_offset_11120 page_offset 0 11120 NULL
104339 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
104340 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
104341 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
104342 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
104343 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
104344 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
104345 +__swab16p_11220 __swab16p 0 11220 NULL
104346 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
104347 +mmap_region_11247 mmap_region 0-2 11247 NULL
104348 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
104349 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
104350 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
104351 +cru_detect_11272 cru_detect 1 11272 NULL
104352 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
104353 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
104354 +construct_key_11329 construct_key 3 11329 NULL nohasharray
104355 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
104356 +next_segment_11330 next_segment 0-2-1 11330 NULL
104357 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
104358 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
104359 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
104360 +sel_write_create_11353 sel_write_create 3 11353 NULL
104361 +handle_unit_11355 handle_unit 0-1 11355 NULL
104362 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
104363 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
104364 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
104365 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
104366 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
104367 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
104368 +str_to_user_11411 str_to_user 2 11411 NULL
104369 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
104370 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
104371 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
104372 +trace_options_read_11419 trace_options_read 3 11419 NULL
104373 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
104374 +prepare_image_11424 prepare_image 0 11424 NULL
104375 +vring_size_11426 vring_size 0-1-2 11426 NULL
104376 +bttv_read_11432 bttv_read 3 11432 NULL
104377 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
104378 +swp_offset_11475 swp_offset 0 11475 NULL
104379 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
104380 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
104381 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
104382 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
104383 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
104384 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
104385 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
104386 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
104387 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
104388 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
104389 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
104390 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
104391 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
104392 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
104393 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
104394 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
104395 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
104396 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
104397 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
104398 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
104399 +split_11691 split 2 11691 NULL
104400 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
104401 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
104402 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
104403 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
104404 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
104405 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
104406 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
104407 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
104408 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
104409 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
104410 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
104411 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
104412 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
104413 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
104414 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
104415 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
104416 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
104417 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
104418 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
104419 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
104420 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
104421 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
104422 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
104423 +atmel_read16_11981 atmel_read16 0 11981 NULL
104424 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
104425 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
104426 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
104427 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
104428 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
104429 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
104430 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
104431 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
104432 +set_powered_12129 set_powered 4 12129 NULL
104433 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
104434 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
104435 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
104436 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
104437 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
104438 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
104439 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
104440 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
104441 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
104442 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
104443 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
104444 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
104445 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
104446 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
104447 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
104448 +scaled_div_12201 scaled_div 1-2 12201 NULL
104449 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
104450 +receive_copy_12216 receive_copy 3 12216 NULL
104451 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
104452 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
104453 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
104454 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
104455 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
104456 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
104457 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
104458 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
104459 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
104460 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
104461 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
104462 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
104463 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
104464 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
104465 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
104466 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
104467 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
104468 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
104469 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
104470 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
104471 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
104472 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
104473 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
104474 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
104475 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
104476 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
104477 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
104478 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
104479 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
104480 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
104481 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
104482 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
104483 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
104484 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
104485 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
104486 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
104487 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
104488 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
104489 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
104490 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
104491 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
104492 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
104493 +wb_create_12651 wb_create 1 12651 NULL
104494 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
104495 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
104496 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
104497 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
104498 +ivtv_write_12721 ivtv_write 3 12721 NULL
104499 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
104500 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
104501 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
104502 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
104503 +listxattr_12769 listxattr 3 12769 NULL
104504 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
104505 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
104506 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
104507 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
104508 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
104509 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
104510 +readq_12825 readq 0 12825 NULL
104511 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
104512 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
104513 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
104514 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
104515 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
104516 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
104517 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
104518 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
104519 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
104520 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
104521 +bm_status_write_12964 bm_status_write 3 12964 NULL
104522 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
104523 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
104524 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
104525 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
104526 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
104527 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
104528 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
104529 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
104530 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
104531 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
104532 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
104533 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
104534 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
104535 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
104536 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
104537 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
104538 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
104539 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
104540 +blk_update_request_13146 blk_update_request 3 13146 NULL
104541 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
104542 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
104543 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
104544 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
104545 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
104546 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
104547 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
104548 +comedi_read_13199 comedi_read 3 13199 NULL
104549 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
104550 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
104551 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
104552 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
104553 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
104554 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
104555 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
104556 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
104557 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
104558 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
104559 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
104560 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
104561 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
104562 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
104563 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
104564 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
104565 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
104566 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
104567 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
104568 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
104569 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
104570 +cache_ctr_13364 cache_ctr 2 13364 NULL
104571 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
104572 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
104573 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
104574 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
104575 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
104576 +sky2_receive_13407 sky2_receive 2 13407 NULL
104577 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
104578 +keyring_read_13438 keyring_read 3 13438 NULL
104579 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
104580 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
104581 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
104582 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
104583 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
104584 +core_status_13515 core_status 4 13515 NULL
104585 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
104586 +bm_init_13529 bm_init 2 13529 NULL
104587 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
104588 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
104589 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
104590 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
104591 +sys_madvise_13569 sys_madvise 1 13569 NULL
104592 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
104593 +cache_write_13589 cache_write 3 13589 NULL
104594 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
104595 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
104596 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
104597 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
104598 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
104599 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
104600 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
104601 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
104602 +packet_snd_13634 packet_snd 3 13634 NULL
104603 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
104604 +cache_downcall_13666 cache_downcall 3 13666 NULL
104605 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
104606 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
104607 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
104608 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
104609 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
104610 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
104611 +random_read_13815 random_read 3 13815 NULL
104612 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
104613 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
104614 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
104615 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
104616 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
104617 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
104618 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
104619 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
104620 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
104621 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
104622 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
104623 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
104624 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
104625 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
104626 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
104627 +com90xx_found_13974 com90xx_found 3 13974 NULL
104628 +qcam_read_13977 qcam_read 3 13977 NULL
104629 +dsp_read_13980 dsp_read 2 13980 NULL
104630 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
104631 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
104632 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
104633 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
104634 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
104635 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
104636 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
104637 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
104638 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
104639 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
104640 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
104641 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
104642 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104643 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
104644 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
104645 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
104646 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104647 +em_canid_change_14150 em_canid_change 3 14150 NULL
104648 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104649 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104650 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104651 +alloc_async_14208 alloc_async 1 14208 NULL
104652 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
104653 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104654 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
104655 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104656 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
104657 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
104658 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
104659 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
104660 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
104661 +rr_status_14293 rr_status 5 14293 NULL
104662 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104663 +oo_objects_14319 oo_objects 0 14319 NULL
104664 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104665 +scsi2int_14358 scsi2int 0 14358 NULL
104666 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104667 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104668 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104669 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104670 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104671 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104672 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104673 +block_size_14443 block_size 0 14443 NULL
104674 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
104675 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104676 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104677 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
104678 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104679 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
104680 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
104681 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104682 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104683 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
104684 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
104685 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
104686 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
104687 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
104688 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
104689 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
104690 +dbJoin_14644 dbJoin 0 14644 NULL
104691 +profile_replace_14652 profile_replace 3 14652 NULL
104692 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
104693 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
104694 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
104695 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
104696 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
104697 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
104698 +get_bio_block_14714 get_bio_block 0 14714 NULL
104699 +vfd_write_14717 vfd_write 3 14717 NULL
104700 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
104701 +raid1_resize_14740 raid1_resize 2 14740 NULL
104702 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
104703 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
104704 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
104705 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
104706 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
104707 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
104708 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
104709 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
104710 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
104711 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
104712 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
104713 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
104714 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
104715 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
104716 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
104717 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
104718 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
104719 +unifi_read_14899 unifi_read 3 14899 NULL
104720 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
104721 +krealloc_14908 krealloc 2 14908 NULL
104722 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
104723 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
104724 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
104725 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
104726 +queue_cnt_14951 queue_cnt 0 14951 NULL
104727 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
104728 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
104729 +setkey_14987 setkey 3 14987 NULL nohasharray
104730 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
104731 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
104732 +vmap_15025 vmap 2 15025 NULL
104733 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
104734 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
104735 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
104736 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
104737 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
104738 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
104739 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
104740 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
104741 +start_port_15124 start_port 0 15124 NULL
104742 +memchr_15126 memchr 0 15126 NULL
104743 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
104744 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
104745 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
104746 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
104747 +reserve_resources_15194 reserve_resources 3 15194 NULL
104748 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
104749 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
104750 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
104751 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
104752 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
104753 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
104754 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
104755 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
104756 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
104757 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
104758 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
104759 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
104760 +ioread16_15342 ioread16 0 15342 NULL
104761 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
104762 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
104763 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
104764 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
104765 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
104766 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
104767 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
104768 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
104769 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
104770 +get_modalias_15406 get_modalias 2 15406 NULL
104771 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
104772 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
104773 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
104774 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
104775 +memweight_15450 memweight 2 15450 NULL
104776 +vmalloc_15464 vmalloc 1 15464 NULL
104777 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
104778 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104779 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104780 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
104781 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
104782 +persistent_status_15574 persistent_status 4 15574 NULL
104783 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104784 +vme_user_write_15587 vme_user_write 3 15587 NULL
104785 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
104786 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104787 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104788 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104789 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
104790 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104791 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
104792 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104793 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104794 +fs_path_add_15648 fs_path_add 3 15648 NULL
104795 +xsd_read_15653 xsd_read 3 15653 NULL
104796 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
104797 +unix_bind_15668 unix_bind 3 15668 NULL
104798 +dm_read_15674 dm_read 3 15674 NULL
104799 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104800 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
104801 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
104802 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104803 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
104804 +do_test_15766 do_test 1 15766 NULL
104805 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
104806 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104807 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
104808 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
104809 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
104810 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104811 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
104812 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
104813 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104814 +table_size_15851 table_size 0-1-2 15851 NULL
104815 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
104816 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104817 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104818 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104819 +native_read_msr_15905 native_read_msr 0 15905 NULL
104820 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104821 +power_read_15939 power_read 3 15939 NULL
104822 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104823 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
104824 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
104825 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
104826 +frame_alloc_15981 frame_alloc 4 15981 NULL
104827 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
104828 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104829 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104830 +got_frame_16028 got_frame 2 16028 NULL
104831 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104832 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104833 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104834 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104835 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104836 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104837 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104838 +fsm_init_16134 fsm_init 2 16134 NULL
104839 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
104840 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104841 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
104842 +mapping_level_16188 mapping_level 2 16188 NULL
104843 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104844 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104845 +create_table_16213 create_table 2 16213 NULL
104846 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104847 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104848 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
104849 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
104850 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
104851 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104852 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
104853 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104854 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104855 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104856 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
104857 +account_16283 account 0-2-4 16283 NULL nohasharray
104858 +mirror_status_16283 mirror_status 5 16283 &account_16283
104859 +retry_instruction_16285 retry_instruction 2 16285 NULL
104860 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104861 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104862 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104863 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104864 +wb_map_16301 wb_map 2 16301 NULL
104865 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104866 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104867 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104868 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104869 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
104870 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104871 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104872 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104873 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104874 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104875 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104876 +raid10_resize_16537 raid10_resize 2 16537 NULL
104877 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
104878 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104879 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104880 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
104881 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104882 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104883 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
104884 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
104885 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104886 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
104887 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104888 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104889 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104890 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104891 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104892 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104893 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104894 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104895 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
104896 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104897 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104898 +st_write_16874 st_write 3 16874 NULL
104899 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104900 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
104901 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104902 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104903 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
104904 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104905 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
104906 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104907 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104908 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104909 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104910 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104911 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104912 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104913 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
104914 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104915 +mac_address_string_17091 mac_address_string 0 17091 NULL
104916 +entry_length_17093 entry_length 0 17093 NULL
104917 +sys_preadv_17100 sys_preadv 3 17100 NULL
104918 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104919 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
104920 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104921 +sep_read_17161 sep_read 3 17161 NULL
104922 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104923 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104924 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104925 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
104926 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104927 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104928 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104929 +to_oblock_17254 to_oblock 0-1 17254 NULL
104930 +unpack_value_17259 unpack_value 1 17259 NULL
104931 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
104932 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104933 +alloc_ep_17269 alloc_ep 1 17269 NULL
104934 +pg_read_17276 pg_read 3 17276 NULL
104935 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104936 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104937 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104938 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104939 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104940 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104941 +skb_pad_17302 skb_pad 2 17302 NULL
104942 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104943 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104944 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
104945 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104946 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104947 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
104948 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104949 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104950 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104951 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104952 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104953 +compat_cmd_17465 compat_cmd 2 17465 NULL
104954 +probe_bios_17467 probe_bios 1 17467 NULL
104955 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104956 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
104957 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104958 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
104959 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
104960 +copy_from_user_17559 copy_from_user 3 17559 NULL
104961 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
104962 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
104963 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
104964 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
104965 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
104966 +osst_execute_17607 osst_execute 7-6 17607 NULL
104967 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
104968 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
104969 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
104970 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
104971 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
104972 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
104973 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
104974 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
104975 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
104976 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
104977 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
104978 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
104979 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
104980 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
104981 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
104982 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
104983 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
104984 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
104985 +perf_clock_17787 perf_clock 0 17787 NULL
104986 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
104987 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104988 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104989 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104990 +count_leafs_17842 count_leafs 0 17842 NULL
104991 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104992 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104993 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104994 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
104995 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104996 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104997 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
104998 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104999 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
105000 +recover_head_17904 recover_head 3 17904 NULL
105001 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
105002 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
105003 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
105004 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
105005 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
105006 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
105007 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
105008 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
105009 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
105010 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
105011 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
105012 +fill_read_18019 fill_read 0 18019 NULL
105013 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
105014 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
105015 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
105016 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
105017 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
105018 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
105019 +packet_came_18072 packet_came 3 18072 NULL
105020 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
105021 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
105022 +get_vm_area_18080 get_vm_area 1 18080 NULL
105023 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
105024 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
105025 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
105026 +svc_getnl_18120 svc_getnl 0 18120 NULL
105027 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
105028 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
105029 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
105030 +_has_tag_18169 _has_tag 2 18169 NULL
105031 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
105032 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
105033 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
105034 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
105035 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
105036 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
105037 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
105038 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
105039 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
105040 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
105041 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
105042 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
105043 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
105044 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
105045 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
105046 +um_idi_write_18293 um_idi_write 3 18293 NULL
105047 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
105048 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
105049 +vga_r_18310 vga_r 0 18310 NULL
105050 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
105051 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
105052 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
105053 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
105054 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
105055 +ep_io_18367 ep_io 0 18367 NULL
105056 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
105057 +ci_role_write_18388 ci_role_write 3 18388 NULL
105058 +__video_register_device_18399 __video_register_device 3 18399 NULL
105059 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
105060 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
105061 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
105062 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
105063 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
105064 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
105065 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
105066 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
105067 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
105068 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
105069 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
105070 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
105071 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
105072 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
105073 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
105074 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
105075 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
105076 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
105077 +debug_output_18575 debug_output 3 18575 NULL
105078 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
105079 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
105080 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
105081 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
105082 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
105083 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
105084 +from_buffer_18625 from_buffer 3 18625 NULL
105085 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
105086 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
105087 +unmap_page_18665 unmap_page 2-3 18665 NULL
105088 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
105089 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
105090 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
105091 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
105092 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
105093 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
105094 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
105095 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
105096 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
105097 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
105098 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
105099 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
105100 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
105101 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
105102 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
105103 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
105104 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
105105 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
105106 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
105107 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
105108 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
105109 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
105110 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
105111 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
105112 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
105113 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
105114 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
105115 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
105116 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
105117 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
105118 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
105119 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
105120 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
105121 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
105122 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
105123 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
105124 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
105125 +huge_page_size_19008 huge_page_size 0 19008 NULL
105126 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
105127 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
105128 +revalidate_19043 revalidate 2 19043 NULL
105129 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
105130 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
105131 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
105132 +msix_map_region_19072 msix_map_region 2 19072 NULL
105133 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
105134 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
105135 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
105136 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
105137 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
105138 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
105139 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
105140 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
105141 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
105142 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
105143 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
105144 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
105145 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
105146 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
105147 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
105148 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
105149 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
105150 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
105151 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
105152 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
105153 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
105154 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
105155 +qc_capture_19298 qc_capture 3 19298 NULL
105156 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
105157 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
105158 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
105159 +debug_read_19322 debug_read 3 19322 NULL
105160 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
105161 +closure_sub_19359 closure_sub 2 19359 NULL
105162 +read_zero_19366 read_zero 3 19366 NULL
105163 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
105164 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
105165 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
105166 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
105167 +__phys_addr_19434 __phys_addr 0 19434 NULL
105168 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
105169 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
105170 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
105171 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
105172 +sky2_read16_19475 sky2_read16 0 19475 NULL
105173 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
105174 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
105175 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
105176 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
105177 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
105178 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
105179 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
105180 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
105181 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
105182 +nfsd_read_19568 nfsd_read 5 19568 NULL
105183 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
105184 +bm_status_read_19583 bm_status_read 3 19583 NULL
105185 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
105186 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
105187 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
105188 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
105189 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
105190 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
105191 +bio_detain_19690 bio_detain 2 19690 NULL
105192 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
105193 +read_reg_19723 read_reg 0 19723 NULL
105194 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
105195 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
105196 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
105197 +p9_client_read_19750 p9_client_read 5 19750 NULL
105198 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
105199 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
105200 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
105201 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
105202 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
105203 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
105204 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
105205 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
105206 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
105207 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
105208 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
105209 +__nla_put_19857 __nla_put 3 19857 NULL
105210 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
105211 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
105212 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
105213 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
105214 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
105215 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
105216 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
105217 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
105218 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
105219 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
105220 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
105221 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
105222 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
105223 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
105224 +team_options_register_20091 team_options_register 3 20091 NULL
105225 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
105226 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
105227 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
105228 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
105229 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
105230 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
105231 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
105232 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
105233 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
105234 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
105235 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
105236 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
105237 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
105238 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
105239 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
105240 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
105241 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
105242 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
105243 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
105244 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
105245 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
105246 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
105247 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
105248 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
105249 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
105250 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
105251 +read_buf_20469 read_buf 2 20469 NULL
105252 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
105253 +fast_user_write_20494 fast_user_write 5 20494 NULL
105254 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
105255 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
105256 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
105257 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
105258 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
105259 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
105260 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
105261 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
105262 +venus_create_20555 venus_create 4 20555 NULL
105263 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
105264 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
105265 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
105266 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
105267 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
105268 +lirc_write_20604 lirc_write 3 20604 NULL
105269 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
105270 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
105271 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
105272 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
105273 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
105274 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
105275 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
105276 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
105277 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
105278 +cpumask_size_20683 cpumask_size 0 20683 NULL
105279 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
105280 +gru_vtop_20689 gru_vtop 2 20689 NULL
105281 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
105282 +__maestro_read_20700 __maestro_read 0 20700 NULL
105283 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
105284 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
105285 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
105286 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
105287 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
105288 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
105289 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
105290 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
105291 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
105292 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
105293 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
105294 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
105295 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
105296 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
105297 +sys_sendto_20809 sys_sendto 6 20809 NULL
105298 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
105299 +strndup_user_20819 strndup_user 2 20819 NULL
105300 +calc_layout_20829 calc_layout 3 20829 NULL
105301 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
105302 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
105303 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
105304 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
105305 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
105306 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
105307 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
105308 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
105309 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
105310 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
105311 +htable_bits_20933 htable_bits 0 20933 NULL
105312 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
105313 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
105314 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
105315 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
105316 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
105317 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
105318 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
105319 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
105320 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
105321 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
105322 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
105323 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
105324 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
105325 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
105326 +multipath_status_21094 multipath_status 5 21094 NULL
105327 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
105328 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
105329 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
105330 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
105331 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
105332 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
105333 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
105334 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
105335 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
105336 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
105337 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
105338 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
105339 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
105340 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
105341 +input_ff_create_21240 input_ff_create 2 21240 NULL
105342 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
105343 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
105344 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
105345 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
105346 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
105347 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
105348 +add_res_range_21310 add_res_range 4 21310 NULL
105349 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
105350 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
105351 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
105352 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
105353 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
105354 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
105355 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
105356 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
105357 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
105358 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
105359 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
105360 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
105361 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
105362 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
105363 +concat_writev_21451 concat_writev 3 21451 NULL
105364 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
105365 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
105366 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
105367 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
105368 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
105369 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
105370 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
105371 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
105372 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
105373 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
105374 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
105375 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
105376 +validate_nnode_21638 validate_nnode 0 21638 NULL
105377 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
105378 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
105379 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
105380 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
105381 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
105382 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
105383 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
105384 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
105385 +vm_brk_21739 vm_brk 1 21739 NULL
105386 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
105387 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
105388 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
105389 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
105390 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
105391 +min_odd_21802 min_odd 0 21802 NULL
105392 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
105393 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
105394 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
105395 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
105396 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
105397 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
105398 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
105399 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
105400 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
105401 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
105402 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
105403 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
105404 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
105405 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
105406 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
105407 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
105408 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
105409 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
105410 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
105411 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
105412 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
105413 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
105414 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
105415 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
105416 +write_opcode_22082 write_opcode 2 22082 NULL
105417 +mem_rw_22085 mem_rw 3 22085 NULL
105418 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
105419 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
105420 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
105421 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
105422 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
105423 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
105424 +compat_insn_22142 compat_insn 2 22142 NULL
105425 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
105426 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
105427 +fls_22210 fls 0 22210 NULL
105428 +mem_write_22232 mem_write 3 22232 NULL
105429 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
105430 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
105431 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
105432 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
105433 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
105434 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
105435 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
105436 +extend_brk_22301 extend_brk 0 22301 NULL
105437 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
105438 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
105439 +get_segment_base_22324 get_segment_base 0 22324 NULL
105440 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
105441 +atomic_read_22342 atomic_read 0 22342 NULL
105442 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
105443 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
105444 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
105445 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
105446 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
105447 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
105448 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
105449 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
105450 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
105451 +zoran_write_22404 zoran_write 3 22404 NULL
105452 +queue_reply_22416 queue_reply 3 22416 NULL
105453 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
105454 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
105455 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
105456 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
105457 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
105458 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
105459 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105460 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105461 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105462 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
105463 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
105464 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
105465 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
105466 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105467 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
105468 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105469 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105470 +snapshot_read_22601 snapshot_read 3 22601 NULL
105471 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105472 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105473 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105474 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105475 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105476 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105477 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
105478 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
105479 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
105480 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105481 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
105482 +map_22700 map 2 22700 NULL
105483 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105484 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
105485 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
105486 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105487 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105488 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105489 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105490 +print_frame_22769 print_frame 0 22769 NULL
105491 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105492 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
105493 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105494 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105495 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
105496 +create_attr_set_22861 create_attr_set 1 22861 NULL
105497 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105498 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105499 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105500 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105501 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
105502 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
105503 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
105504 +vme_get_size_22964 vme_get_size 0 22964 NULL
105505 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
105506 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
105507 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
105508 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
105509 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
105510 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
105511 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
105512 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
105513 +st_status_23032 st_status 5 23032 NULL
105514 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
105515 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
105516 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
105517 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
105518 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
105519 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
105520 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
105521 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
105522 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
105523 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
105524 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
105525 +fls_long_23096 fls_long 0 23096 NULL
105526 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
105527 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
105528 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
105529 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
105530 +__clear_user_23118 __clear_user 0 23118 NULL
105531 +dm_write_async_23120 dm_write_async 3 23120 NULL
105532 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
105533 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
105534 +read_file_ani_23161 read_file_ani 3 23161 NULL
105535 +ioremap_23172 ioremap 1-2 23172 NULL
105536 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
105537 +usblp_write_23178 usblp_write 3 23178 NULL
105538 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
105539 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
105540 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
105541 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
105542 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
105543 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
105544 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
105545 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
105546 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
105547 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
105548 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
105549 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
105550 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
105551 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
105552 +doc_probe_23285 doc_probe 1 23285 NULL
105553 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
105554 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
105555 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
105556 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
105557 +page_readlink_23346 page_readlink 3 23346 NULL
105558 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
105559 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
105560 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
105561 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
105562 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
105563 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
105564 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
105565 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
105566 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
105567 +event_filter_read_23494 event_filter_read 3 23494 NULL
105568 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
105569 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
105570 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
105571 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
105572 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
105573 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
105574 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
105575 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
105576 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
105577 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
105578 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
105579 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
105580 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
105581 +sInW_23663 sInW 0 23663 NULL
105582 +SyS_connect_23669 SyS_connect 3 23669 NULL
105583 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
105584 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
105585 +cx18_read_23699 cx18_read 3 23699 NULL
105586 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
105587 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
105588 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
105589 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
105590 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
105591 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
105592 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
105593 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
105594 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
105595 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
105596 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
105597 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
105598 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
105599 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
105600 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
105601 +p54_init_common_23850 p54_init_common 1 23850 NULL
105602 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
105603 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
105604 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
105605 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
105606 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105607 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
105608 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105609 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105610 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105611 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105612 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105613 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
105614 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
105615 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105616 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105617 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105618 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105619 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
105620 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105621 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105622 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105623 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
105624 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105625 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105626 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105627 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105628 +mpu401_read_24126 mpu401_read 3 24126 NULL
105629 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105630 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105631 +set_discard_24162 set_discard 2 24162 NULL
105632 +adu_read_24177 adu_read 3 24177 NULL
105633 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105634 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105635 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105636 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105637 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
105638 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105639 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105640 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105641 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105642 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105643 +thin_status_24278 thin_status 5 24278 NULL
105644 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
105645 +msg_size_24288 msg_size 0 24288 NULL
105646 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
105647 +map_page_24298 map_page 3-4 24298 NULL
105648 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105649 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
105650 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105651 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105652 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105653 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
105654 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
105655 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105656 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105657 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105658 +igetword_24373 igetword 0 24373 NULL
105659 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105660 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
105661 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105662 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105663 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
105664 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
105665 +smk_user_access_24440 smk_user_access 3 24440 NULL
105666 +page_address_24444 page_address 0 24444 NULL
105667 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105668 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
105669 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105670 +pd_video_read_24510 pd_video_read 3 24510 NULL
105671 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105672 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105673 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
105674 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105675 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105676 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
105677 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105678 +count_preds_24600 count_preds 0 24600 NULL
105679 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
105680 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105681 +context_alloc_24645 context_alloc 3 24645 NULL
105682 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105683 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
105684 +read_fs_24717 read_fs 0 24717 NULL
105685 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105686 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105687 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
105688 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105689 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105690 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
105691 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
105692 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105693 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
105694 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105695 +cache_read_24790 cache_read 3 24790 NULL
105696 +unpack_str_24798 unpack_str 0 24798 NULL
105697 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105698 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105699 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105700 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105701 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105702 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105703 +setup_buffering_24872 setup_buffering 3 24872 NULL
105704 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
105705 +queues_read_24877 queues_read 3 24877 NULL nohasharray
105706 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
105707 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105708 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
105709 +next_token_24929 next_token 0 24929 NULL
105710 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
105711 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
105712 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105713 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
105714 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105715 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105716 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
105717 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105718 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105719 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105720 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105721 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105722 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105723 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105724 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
105725 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105726 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
105727 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
105728 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105729 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
105730 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105731 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
105732 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105733 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105734 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
105735 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
105736 +stripe_status_25259 stripe_status 5 25259 NULL
105737 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105738 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105739 +vfs_writev_25278 vfs_writev 3 25278 NULL
105740 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105741 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
105742 +help_25316 help 5 25316 NULL nohasharray
105743 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
105744 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105745 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105746 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
105747 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105748 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105749 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105750 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105751 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105752 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
105753 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105754 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105755 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105756 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
105757 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105758 +sb_permission_25523 sb_permission 0 25523 NULL
105759 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105760 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105761 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
105762 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
105763 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
105764 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
105765 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
105766 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
105767 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
105768 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
105769 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
105770 +__direct_map_25647 __direct_map 5-6 25647 NULL
105771 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
105772 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
105773 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
105774 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
105775 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
105776 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
105777 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
105778 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
105779 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
105780 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
105781 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
105782 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
105783 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
105784 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
105785 +sg_read_25799 sg_read 3 25799 NULL
105786 +system_enable_read_25815 system_enable_read 3 25815 NULL
105787 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
105788 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
105789 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
105790 +parport_read_25855 parport_read 0 25855 NULL
105791 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
105792 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
105793 +key_attr_size_25865 key_attr_size 0 25865 NULL
105794 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
105795 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
105796 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
105797 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
105798 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
105799 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
105800 +rcname_read_25919 rcname_read 3 25919 NULL
105801 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
105802 +key_flags_read_25931 key_flags_read 3 25931 NULL
105803 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
105804 +flush_25957 flush 2 25957 NULL
105805 +video_register_device_25971 video_register_device 3 25971 NULL
105806 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
105807 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
105808 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
105809 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
105810 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
105811 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
105812 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
105813 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
105814 +tun_do_read_26047 tun_do_read 5 26047 NULL
105815 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
105816 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
105817 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
105818 +skb_cow_26138 skb_cow 2 26138 NULL
105819 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
105820 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
105821 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
105822 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
105823 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
105824 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
105825 +disk_devt_26180 disk_devt 0 26180 NULL
105826 +get_registers_26187 get_registers 3 26187 NULL
105827 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
105828 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
105829 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
105830 +mce_write_26201 mce_write 3 26201 NULL
105831 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
105832 +bio_split_26235 bio_split 2 26235 NULL
105833 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
105834 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
105835 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
105836 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
105837 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
105838 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
105839 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
105840 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
105841 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
105842 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
105843 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
105844 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
105845 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
105846 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
105847 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
105848 +read_vmcore_26501 read_vmcore 3 26501 NULL
105849 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
105850 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
105851 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
105852 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
105853 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
105854 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
105855 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
105856 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
105857 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
105858 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
105859 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
105860 +pack_value_26625 pack_value 1 26625 NULL
105861 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
105862 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
105863 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
105864 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
105865 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
105866 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
105867 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
105868 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
105869 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
105870 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
105871 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
105872 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
105873 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
105874 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
105875 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
105876 +smk_write_load_26829 smk_write_load 3 26829 NULL
105877 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
105878 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
105879 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
105880 +scnprint_id_26842 scnprint_id 3 26842 NULL
105881 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
105882 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
105883 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
105884 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
105885 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
105886 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
105887 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
105888 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
105889 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
105890 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
105891 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
105892 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
105893 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
105894 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
105895 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
105896 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
105897 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
105898 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
105899 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
105900 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
105901 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
105902 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
105903 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
105904 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
105905 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
105906 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
105907 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
105908 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
105909 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
105910 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
105911 +pms_capture_27142 pms_capture 4 27142 NULL
105912 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
105913 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
105914 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
105915 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
105916 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
105917 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
105918 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
105919 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
105920 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
105921 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
105922 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
105923 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
105924 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
105925 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
105926 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
105927 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
105928 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
105929 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
105930 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
105931 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
105932 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
105933 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
105934 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
105935 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
105936 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
105937 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
105938 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
105939 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
105940 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
105941 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
105942 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
105943 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
105944 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
105945 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
105946 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
105947 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
105948 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
105949 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
105950 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
105951 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
105952 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
105953 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
105954 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
105955 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
105956 +qword_get_27670 qword_get 0 27670 NULL
105957 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
105958 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
105959 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
105960 +evm_write_key_27715 evm_write_key 3 27715 NULL
105961 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
105962 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
105963 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
105964 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
105965 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
105966 +kcalloc_27770 kcalloc 1-2 27770 NULL
105967 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
105968 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
105969 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
105970 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
105971 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
105972 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
105973 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
105974 +read_profile_27859 read_profile 3 27859 NULL
105975 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
105976 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
105977 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
105978 +gluebi_write_27905 gluebi_write 3 27905 NULL
105979 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
105980 +bm_find_next_27929 bm_find_next 2 27929 NULL
105981 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
105982 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
105983 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
105984 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
105985 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105986 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105987 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
105988 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105989 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105990 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105991 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
105992 +pool_status_28055 pool_status 5 28055 NULL
105993 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105994 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105995 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105996 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
105997 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105998 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
105999 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
106000 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
106001 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
106002 +video_read_28148 video_read 3 28148 NULL
106003 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
106004 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
106005 +vread_28173 vread 0 28173 NULL
106006 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
106007 +d_path_28198 d_path 0 28198 NULL
106008 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
106009 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
106010 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
106011 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
106012 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
106013 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
106014 +usemap_size_28281 usemap_size 0 28281 NULL
106015 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
106016 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
106017 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
106018 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
106019 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
106020 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
106021 +snapshot_write_28351 snapshot_write 3 28351 NULL
106022 +sys_writev_28384 sys_writev 3 28384 NULL
106023 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
106024 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
106025 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
106026 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
106027 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
106028 +__split_large_page_28429 __split_large_page 2 28429 NULL
106029 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
106030 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
106031 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
106032 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
106033 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
106034 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
106035 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
106036 +max_response_pages_28492 max_response_pages 0 28492 NULL
106037 +clear_discard_28494 clear_discard 2 28494 NULL
106038 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
106039 +__next_node_28521 __next_node 1 28521 NULL
106040 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
106041 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
106042 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
106043 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
106044 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
106045 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
106046 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
106047 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
106048 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
106049 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
106050 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
106051 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
106052 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
106053 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
106054 +_set_range_28627 _set_range 3 28627 NULL
106055 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
106056 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
106057 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
106058 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
106059 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
106060 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
106061 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
106062 +spi_execute_28736 spi_execute 5 28736 NULL
106063 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
106064 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
106065 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
106066 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
106067 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
106068 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
106069 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
106070 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
106071 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
106072 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
106073 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
106074 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
106075 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
106076 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
106077 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
106078 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
106079 +to_cblock_28899 to_cblock 0-1 28899 NULL
106080 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
106081 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
106082 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
106083 +push_rx_28939 push_rx 3 28939 NULL
106084 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
106085 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
106086 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
106087 +bin_uuid_28999 bin_uuid 3 28999 NULL
106088 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
106089 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
106090 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
106091 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
106092 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
106093 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
106094 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
106095 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
106096 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
106097 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
106098 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
106099 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
106100 +snprintf_29125 snprintf 0 29125 NULL
106101 +iov_shorten_29130 iov_shorten 0 29130 NULL
106102 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
106103 +reshape_ring_29147 reshape_ring 2 29147 NULL
106104 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
106105 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
106106 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
106107 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
106108 +__mm_populate_29204 __mm_populate 1 29204 NULL
106109 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
106110 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
106111 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
106112 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
106113 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
106114 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
106115 +recover_peb_29238 recover_peb 6-7 29238 NULL
106116 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
106117 +block_div_29268 block_div 0-1-2 29268 NULL
106118 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
106119 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
106120 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
106121 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
106122 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
106123 +tun_put_user_29337 tun_put_user 5 29337 NULL
106124 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
106125 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
106126 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
106127 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
106128 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
106129 +mempool_create_29437 mempool_create 1 29437 NULL
106130 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
106131 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
106132 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
106133 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
106134 +do_register_entry_29478 do_register_entry 4 29478 NULL
106135 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
106136 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
106137 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
106138 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
106139 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
106140 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
106141 +set_brk_29551 set_brk 1 29551 NULL nohasharray
106142 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
106143 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
106144 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
106145 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
106146 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
106147 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
106148 +slots_per_page_29601 slots_per_page 0 29601 NULL
106149 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
106150 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
106151 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
106152 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
106153 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
106154 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
106155 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
106156 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
106157 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
106158 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
106159 +probes_write_29711 probes_write 3 29711 NULL
106160 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
106161 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
106162 +std_nic_write_29752 std_nic_write 3 29752 NULL
106163 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
106164 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
106165 +dbAlloc_29794 dbAlloc 0 29794 NULL
106166 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
106167 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
106168 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
106169 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
106170 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
106171 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
106172 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
106173 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
106174 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
106175 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
106176 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
106177 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
106178 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
106179 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
106180 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
106181 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
106182 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
106183 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
106184 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
106185 +drp_wmove_30043 drp_wmove 4 30043 NULL
106186 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
106187 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
106188 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
106189 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
106190 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
106191 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
106192 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
106193 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
106194 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
106195 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
106196 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
106197 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
106198 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
106199 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
106200 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
106201 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
106202 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
106203 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
106204 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
106205 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
106206 +compat_readv_30273 compat_readv 3 30273 NULL
106207 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
106208 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
106209 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
106210 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
106211 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
106212 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
106213 +resource_from_user_30341 resource_from_user 3 30341 NULL
106214 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
106215 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
106216 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
106217 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
106218 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
106219 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
106220 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
106221 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
106222 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
106223 +mq_create_30425 mq_create 1 30425 NULL
106224 +enable_write_30456 enable_write 3 30456 NULL
106225 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
106226 +urandom_read_30462 urandom_read 3 30462 NULL
106227 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
106228 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
106229 +write_head_30481 write_head 4 30481 NULL
106230 +adu_write_30487 adu_write 3 30487 NULL
106231 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
106232 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
106233 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
106234 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
106235 +set_le_30581 set_le 4 30581 NULL
106236 +from_cblock_30582 from_cblock 0-1 30582 NULL
106237 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
106238 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
106239 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
106240 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
106241 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
106242 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
106243 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
106244 +agp_remap_30665 agp_remap 2 30665 NULL
106245 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
106246 +il_free_pages_30692 il_free_pages 2 30692 NULL
106247 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
106248 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
106249 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
106250 +snapshot_status_30744 snapshot_status 5 30744 NULL
106251 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
106252 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
106253 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
106254 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
106255 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
106256 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
106257 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
106258 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
106259 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
106260 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
106261 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
106262 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
106263 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
106264 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
106265 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
106266 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
106267 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
106268 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
106269 +sys_mincore_31079 sys_mincore 1 31079 NULL
106270 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
106271 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
106272 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
106273 +depth_read_31112 depth_read 3 31112 NULL
106274 +ssb_read16_31139 ssb_read16 0 31139 NULL
106275 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
106276 +size_inside_page_31141 size_inside_page 0 31141 NULL
106277 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
106278 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
106279 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
106280 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
106281 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
106282 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
106283 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106284 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106285 +__read_reg_31216 __read_reg 0 31216 NULL
106286 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106287 +cyy_readb_31240 cyy_readb 0 31240 NULL
106288 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106289 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106290 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106291 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106292 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106293 +command_file_write_31318 command_file_write 3 31318 NULL
106294 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106295 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106296 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106297 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
106298 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106299 +inb_31388 inb 0 31388 NULL
106300 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106301 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
106302 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106303 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106304 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106305 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106306 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106307 +do_fcntl_31468 do_fcntl 3 31468 NULL
106308 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106309 +alg_setkey_31485 alg_setkey 3 31485 NULL
106310 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
106311 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
106312 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
106313 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
106314 +hidraw_write_31536 hidraw_write 3 31536 NULL
106315 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
106316 +usbvision_read_31555 usbvision_read 3 31555 NULL
106317 +normalize_31566 normalize 0-1-2 31566 NULL
106318 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
106319 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
106320 +osst_write_31581 osst_write 3 31581 NULL
106321 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
106322 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
106323 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
106324 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
106325 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
106326 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
106327 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
106328 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
106329 +__lgread_31668 __lgread 4 31668 NULL
106330 +symbol_string_31670 symbol_string 0 31670 NULL
106331 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
106332 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
106333 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
106334 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
106335 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
106336 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
106337 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
106338 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
106339 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
106340 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
106341 +muldiv64_31743 muldiv64 2-3 31743 NULL
106342 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
106343 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
106344 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
106345 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
106346 +get_count_order_31800 get_count_order 0 31800 NULL
106347 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
106348 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
106349 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
106350 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
106351 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
106352 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
106353 +xattr_permission_31907 xattr_permission 0 31907 NULL
106354 +new_dir_31919 new_dir 3 31919 NULL
106355 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
106356 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
106357 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
106358 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
106359 +vb2_write_31948 vb2_write 3 31948 NULL
106360 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
106361 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
106362 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
106363 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
106364 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
106365 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
106366 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
106367 +calc_hmac_32010 calc_hmac 3 32010 NULL
106368 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
106369 +aead_len_32021 aead_len 0 32021 NULL
106370 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
106371 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
106372 +stk_read_32038 stk_read 3 32038 NULL
106373 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
106374 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
106375 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
106376 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
106377 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
106378 +bio_alloc_32095 bio_alloc 2 32095 NULL
106379 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
106380 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
106381 +disk_status_32120 disk_status 4 32120 NULL
106382 +venus_link_32165 venus_link 5 32165 NULL
106383 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
106384 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
106385 +load_header_32183 load_header 0 32183 NULL
106386 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
106387 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
106388 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
106389 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
106390 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
106391 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
106392 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
106393 +hex_string_32310 hex_string 0 32310 NULL
106394 +SyS_select_32319 SyS_select 1 32319 NULL
106395 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
106396 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
106397 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
106398 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
106399 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
106400 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
106401 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
106402 +local_clock_32385 local_clock 0 32385 NULL
106403 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
106404 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
106405 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
106406 +log_text_32428 log_text 0 32428 NULL
106407 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
106408 +hid_input_report_32458 hid_input_report 4 32458 NULL
106409 +cache_status_32462 cache_status 5 32462 NULL
106410 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
106411 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
106412 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
106413 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
106414 +disconnect_32521 disconnect 4 32521 NULL
106415 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
106416 +ilo_read_32531 ilo_read 3 32531 NULL
106417 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
106418 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
106419 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
106420 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
106421 +__first_node_32558 __first_node 0 32558 NULL
106422 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106423 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
106424 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106425 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106426 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106427 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106428 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
106429 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106430 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
106431 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106432 +kvmalloc_32646 kvmalloc 1 32646 NULL
106433 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106434 +generic_readlink_32654 generic_readlink 3 32654 NULL
106435 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106436 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
106437 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106438 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
106439 +get_arg_page_32746 get_arg_page 2 32746 NULL
106440 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106441 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106442 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
106443 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106444 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
106445 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106446 +vga_rseq_32848 vga_rseq 0 32848 NULL
106447 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106448 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
106449 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106450 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106451 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
106452 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
106453 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106454 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106455 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106456 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106457 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106458 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
106459 +compat_filldir_32999 compat_filldir 3 32999 NULL
106460 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
106461 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106462 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106463 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106464 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106465 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
106466 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106467 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106468 +alloc_tio_33077 alloc_tio 3 33077 NULL
106469 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106470 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
106471 +write_node_33121 write_node 4 33121 NULL
106472 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
106473 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106474 +__len_within_target_33132 __len_within_target 0 33132 NULL
106475 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106476 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
106477 +pp_read_33210 pp_read 3 33210 NULL
106478 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
106479 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
106480 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106481 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
106482 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106483 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
106484 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106485 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106486 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106487 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
106488 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
106489 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106490 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106491 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106492 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106493 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106494 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106495 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106496 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106497 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
106498 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106499 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106500 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106501 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106502 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
106503 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106504 +create_entry_33479 create_entry 2 33479 NULL
106505 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106506 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106507 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
106508 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106509 +res_counter_read_33499 res_counter_read 4 33499 NULL
106510 +fb_read_33506 fb_read 3 33506 NULL
106511 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106512 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106513 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106514 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106515 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106516 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
106517 +dup_array_33551 dup_array 3 33551 NULL
106518 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
106519 +count_subheaders_33591 count_subheaders 0 33591 NULL
106520 +scsi_execute_33596 scsi_execute 5 33596 NULL
106521 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106522 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
106523 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
106524 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106525 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106526 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106527 +inw_p_33668 inw_p 0 33668 NULL
106528 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106529 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106530 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
106531 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106532 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
106533 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
106534 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
106535 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106536 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106537 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106538 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106539 +Read_hfc_33755 Read_hfc 0 33755 NULL
106540 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106541 +hashtab_create_33769 hashtab_create 3 33769 NULL
106542 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
106543 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106544 +find_next_offset_33804 find_next_offset 3 33804 NULL
106545 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
106546 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106547 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106548 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
106549 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
106550 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106551 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106552 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
106553 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106554 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106555 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106556 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106557 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
106558 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106559 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106560 +ppp_write_34034 ppp_write 3 34034 NULL
106561 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
106562 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106563 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106564 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
106565 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106566 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
106567 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
106568 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106569 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
106570 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106571 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106572 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
106573 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
106574 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106575 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106576 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106577 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106578 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106579 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106580 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
106581 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106582 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106583 +__insert_34349 __insert 2-3 34349 NULL
106584 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
106585 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
106586 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
106587 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
106588 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
106589 +ea_read_34378 ea_read 0 34378 NULL
106590 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
106591 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
106592 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
106593 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
106594 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
106595 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
106596 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
106597 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
106598 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
106599 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
106600 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
106601 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
106602 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
106603 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
106604 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
106605 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
106606 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
106607 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
106608 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
106609 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
106610 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
106611 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
106612 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
106613 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
106614 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
106615 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
106616 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
106617 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
106618 +port_print_34704 port_print 3 34704 NULL
106619 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
106620 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
106621 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
106622 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
106623 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
106624 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
106625 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
106626 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
106627 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
106628 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
106629 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
106630 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
106631 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
106632 +msg_print_text_34889 msg_print_text 0 34889 NULL
106633 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
106634 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
106635 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
106636 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
106637 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
106638 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
106639 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
106640 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
106641 +Realloc_34961 Realloc 2 34961 NULL
106642 +mq_lookup_34990 mq_lookup 2 34990 NULL
106643 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
106644 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
106645 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
106646 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
106647 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
106648 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
106649 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
106650 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
106651 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
106652 +store_ifalias_35088 store_ifalias 4 35088 NULL
106653 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
106654 +capi_write_35104 capi_write 3 35104 NULL nohasharray
106655 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
106656 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
106657 +pointer_35138 pointer 0 35138 NULL
106658 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
106659 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
106660 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
106661 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
106662 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
106663 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
106664 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
106665 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
106666 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
106667 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
106668 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
106669 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
106670 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
106671 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
106672 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
106673 +set_fd_set_35249 set_fd_set 1 35249 NULL
106674 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
106675 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
106676 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
106677 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
106678 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
106679 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
106680 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
106681 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
106682 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
106683 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
106684 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
106685 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
106686 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
106687 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
106688 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
106689 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
106690 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
106691 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
106692 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
106693 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
106694 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
106695 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
106696 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
106697 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
106698 +async_setkey_35521 async_setkey 3 35521 NULL
106699 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
106700 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
106701 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
106702 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
106703 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
106704 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
106705 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
106706 +ReadZReg_35604 ReadZReg 0 35604 NULL
106707 +kernel_readv_35617 kernel_readv 3 35617 NULL
106708 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
106709 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
106710 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
106711 +store_debug_level_35652 store_debug_level 3 35652 NULL
106712 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
106713 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
106714 +dm_table_create_35687 dm_table_create 3 35687 NULL
106715 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
106716 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
106717 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
106718 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
106719 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
106720 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
106721 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
106722 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
106723 +fls64_35862 fls64 0 35862 NULL
106724 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
106725 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
106726 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
106727 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
106728 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
106729 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
106730 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
106731 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
106732 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
106733 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
106734 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
106735 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
106736 +acl_alloc_35979 acl_alloc 1 35979 NULL
106737 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
106738 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
106739 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
106740 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
106741 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
106742 +account_shadowed_36048 account_shadowed 2 36048 NULL
106743 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
106744 +write_emulate_36065 write_emulate 2-4 36065 NULL
106745 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
106746 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
106747 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
106748 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
106749 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
106750 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
106751 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
106752 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
106753 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
106754 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
106755 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
106756 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
106757 +twl_set_36154 twl_set 2 36154 NULL
106758 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
106759 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
106760 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
106761 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
106762 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
106763 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
106764 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
106765 +is_dirty_36223 is_dirty 2 36223 NULL
106766 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
106767 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
106768 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
106769 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
106770 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
106771 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
106772 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
106773 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
106774 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
106775 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
106776 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
106777 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
106778 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
106779 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
106780 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
106781 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
106782 +lc_create_36332 lc_create 4 36332 NULL
106783 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
106784 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
106785 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
106786 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
106787 +to_sector_36361 to_sector 0-1 36361 NULL
106788 +tunables_read_36385 tunables_read 3 36385 NULL
106789 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
106790 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
106791 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
106792 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
106793 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
106794 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
106795 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
106796 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
106797 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
106798 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
106799 +get_param_l_36518 get_param_l 0 36518 NULL
106800 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
106801 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
106802 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
106803 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
106804 +get_entry_len_36549 get_entry_len 0 36549 NULL
106805 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
106806 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
106807 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
106808 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
106809 +__erst_read_36579 __erst_read 0 36579 NULL
106810 +put_cmsg_36589 put_cmsg 4 36589 NULL
106811 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
106812 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
106813 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
106814 +format_decode_36638 format_decode 0 36638 NULL
106815 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
106816 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
106817 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
106818 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
106819 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
106820 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
106821 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
106822 +sched_clock_36717 sched_clock 0 36717 NULL
106823 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
106824 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
106825 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
106826 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
106827 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
106828 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
106829 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
106830 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
106831 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
106832 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
106833 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
106834 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
106835 +cm_write_36858 cm_write 3 36858 NULL
106836 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
106837 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
106838 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
106839 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
106840 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
106841 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
106842 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
106843 +build_key_36931 build_key 1 36931 NULL
106844 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
106845 +write_leb_36957 write_leb 5 36957 NULL
106846 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
106847 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
106848 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
106849 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
106850 +setxattr_37006 setxattr 4 37006 NULL
106851 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
106852 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
106853 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
106854 +parse_command_37079 parse_command 2 37079 NULL
106855 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
106856 +tun_get_user_37094 tun_get_user 5 37094 NULL
106857 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
106858 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
106859 +msg_word_37164 msg_word 0 37164 NULL
106860 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
106861 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
106862 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
106863 +__do_replace_37227 __do_replace 5 37227 NULL
106864 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
106865 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
106866 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
106867 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
106868 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
106869 +c101_run_37279 c101_run 2 37279 NULL
106870 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
106871 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
106872 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
106873 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
106874 +send_msg_37323 send_msg 4 37323 NULL
106875 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
106876 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
106877 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
106878 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
106879 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
106880 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
106881 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
106882 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
106883 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
106884 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
106885 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
106886 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
106887 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
106888 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
106889 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
106890 +__remove_37457 __remove 2 37457 NULL
106891 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
106892 +get_est_timing_37484 get_est_timing 0 37484 NULL
106893 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
106894 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
106895 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
106896 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
106897 +hdr_size_37536 hdr_size 0 37536 NULL
106898 +a2p_37544 a2p 0-1 37544 NULL
106899 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
106900 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
106901 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
106902 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
106903 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
106904 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
106905 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
106906 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
106907 +check_pt_base_37635 check_pt_base 3 37635 NULL
106908 +alloc_fd_37637 alloc_fd 1 37637 NULL
106909 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
106910 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
106911 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
106912 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
106913 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
106914 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
106915 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
106916 +nametbl_header_37698 nametbl_header 2 37698 NULL
106917 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
106918 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
106919 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
106920 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
106921 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
106922 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
106923 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
106924 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
106925 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
106926 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
106927 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
106928 +deny_write_access_37813 deny_write_access 0 37813 NULL
106929 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
106930 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
106931 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
106932 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
106933 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
106934 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
106935 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
106936 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
106937 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
106938 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
106939 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
106940 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
106941 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
106942 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
106943 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
106944 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
106945 +vfs_readv_38011 vfs_readv 3 38011 NULL
106946 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
106947 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
106948 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
106949 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
106950 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
106951 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
106952 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
106953 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
106954 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
106955 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
106956 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
106957 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
106958 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
106959 +ep0_read_38095 ep0_read 3 38095 NULL
106960 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
106961 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
106962 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
106963 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
106964 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
106965 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
106966 +cdev_add_38176 cdev_add 2-3 38176 NULL
106967 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
106968 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
106969 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
106970 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
106971 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
106972 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
106973 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
106974 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
106975 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
106976 +from_dblock_38256 from_dblock 0-1 38256 NULL
106977 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
106978 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
106979 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
106980 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
106981 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
106982 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
106983 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
106984 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
106985 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106986 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
106987 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106988 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
106989 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106990 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
106991 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106992 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106993 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
106994 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106995 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106996 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
106997 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
106998 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106999 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
107000 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
107001 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
107002 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
107003 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
107004 +dev_names_read_38509 dev_names_read 3 38509 NULL
107005 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
107006 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
107007 +set_queue_count_38519 set_queue_count 0 38519 NULL
107008 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
107009 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
107010 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
107011 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
107012 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
107013 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
107014 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
107015 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
107016 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
107017 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
107018 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
107019 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
107020 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
107021 +cma_create_area_38642 cma_create_area 2 38642 NULL
107022 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
107023 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
107024 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
107025 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
107026 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
107027 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
107028 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
107029 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
107030 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
107031 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
107032 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
107033 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
107034 +udf_readpages_38761 udf_readpages 4 38761 NULL
107035 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
107036 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
107037 +err_decode_38804 err_decode 2 38804 NULL
107038 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
107039 +sys_select_38827 sys_select 1 38827 NULL
107040 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
107041 +direct_entry_38836 direct_entry 3 38836 NULL
107042 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
107043 +interfaces_38859 interfaces 2 38859 NULL
107044 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
107045 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
107046 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
107047 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
107048 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
107049 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
107050 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
107051 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
107052 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
107053 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
107054 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
107055 +udf_new_block_38999 udf_new_block 4 38999 NULL
107056 +get_nodes_39012 get_nodes 3 39012 NULL
107057 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
107058 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
107059 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
107060 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
107061 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
107062 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
107063 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
107064 +ea_foreach_39133 ea_foreach 0 39133 NULL
107065 +generic_permission_39150 generic_permission 0 39150 NULL
107066 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
107067 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
107068 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
107069 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
107070 +init_list_set_39188 init_list_set 2-3 39188 NULL
107071 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
107072 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
107073 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
107074 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
107075 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
107076 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
107077 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
107078 +drm_order_39244 drm_order 0 39244 NULL
107079 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
107080 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
107081 +__skb_cow_39254 __skb_cow 2 39254 NULL
107082 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
107083 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
107084 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
107085 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
107086 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
107087 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
107088 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
107089 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
107090 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
107091 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
107092 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
107093 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
107094 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
107095 +__send_to_port_39386 __send_to_port 3 39386 NULL
107096 +user_power_read_39414 user_power_read 3 39414 NULL
107097 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
107098 +sys_semop_39457 sys_semop 3 39457 NULL
107099 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
107100 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
107101 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
107102 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
107103 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
107104 +int_proc_write_39542 int_proc_write 3 39542 NULL
107105 +pp_write_39554 pp_write 3 39554 NULL
107106 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
107107 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
107108 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
107109 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
107110 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
107111 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
107112 +ext_depth_39607 ext_depth 0 39607 NULL
107113 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
107114 +sdio_readb_39618 sdio_readb 0 39618 NULL
107115 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
107116 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
107117 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
107118 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
107119 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
107120 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
107121 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
107122 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
107123 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
107124 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
107125 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
107126 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
107127 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
107128 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
107129 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
107130 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
107131 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
107132 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
107133 +pkt_add_39897 pkt_add 3 39897 NULL
107134 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
107135 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
107136 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
107137 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
107138 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
107139 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
107140 +__spi_async_39932 __spi_async 0 39932 NULL
107141 +__get_order_39935 __get_order 0 39935 NULL
107142 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
107143 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
107144 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
107145 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
107146 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
107147 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
107148 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
107149 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
107150 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
107151 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
107152 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
107153 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
107154 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
107155 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
107156 +add_tty_40055 add_tty 1 40055 NULL nohasharray
107157 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
107158 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
107159 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
107160 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
107161 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
107162 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
107163 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
107164 +pt_write_40159 pt_write 3 40159 NULL
107165 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
107166 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
107167 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
107168 +allocate_probes_40204 allocate_probes 1 40204 NULL
107169 +compat_put_long_40214 compat_put_long 1 40214 NULL
107170 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
107171 +osst_read_40237 osst_read 3 40237 NULL
107172 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
107173 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
107174 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
107175 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
107176 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
107177 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
107178 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
107179 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
107180 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
107181 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
107182 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
107183 +mmio_read_40348 mmio_read 4 40348 NULL
107184 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
107185 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
107186 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
107187 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
107188 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
107189 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
107190 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
107191 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
107192 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
107193 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
107194 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
107195 +tty_write_room_40495 tty_write_room 0 40495 NULL
107196 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
107197 +sg_phys_40507 sg_phys 0 40507 NULL
107198 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
107199 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
107200 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
107201 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
107202 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
107203 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
107204 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
107205 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
107206 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
107207 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
107208 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
107209 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
107210 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
107211 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
107212 +fops_read_40672 fops_read 3 40672 NULL
107213 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
107214 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
107215 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
107216 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
107217 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
107218 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
107219 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
107220 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
107221 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
107222 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
107223 +card_send_command_40757 card_send_command 3 40757 NULL
107224 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
107225 +pg_write_40766 pg_write 3 40766 NULL
107226 +show_list_40775 show_list 3 40775 NULL
107227 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
107228 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
107229 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
107230 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
107231 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
107232 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
107233 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
107234 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
107235 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
107236 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
107237 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
107238 +read_file_queue_40895 read_file_queue 3 40895 NULL
107239 +waiters_read_40902 waiters_read 3 40902 NULL
107240 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
107241 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
107242 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
107243 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
107244 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
107245 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
107246 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
107247 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
107248 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
107249 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
107250 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
107251 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
107252 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
107253 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
107254 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
107255 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107256 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
107257 +dma_attach_41094 dma_attach 5-6 41094 NULL
107258 +provide_user_output_41105 provide_user_output 3 41105 NULL
107259 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107260 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107261 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107262 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107263 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107264 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
107265 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107266 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107267 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
107268 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107269 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107270 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
107271 +erst_read_41260 erst_read 0 41260 NULL
107272 +__fprog_create_41263 __fprog_create 2 41263 NULL
107273 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
107274 +alloc_context_41283 alloc_context 1 41283 NULL
107275 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
107276 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
107277 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107278 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107279 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107280 +kmp_init_41373 kmp_init 2 41373 NULL
107281 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107282 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107283 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
107284 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107285 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107286 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
107287 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107288 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107289 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107290 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
107291 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107292 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107293 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107294 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107295 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107296 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107297 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107298 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
107299 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107300 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107301 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
107302 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
107303 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107304 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
107305 +vga_io_r_41609 vga_io_r 0 41609 NULL
107306 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107307 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
107308 +a2mp_send_41615 a2mp_send 4 41615 NULL
107309 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107310 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107311 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107312 +get_std_timing_41654 get_std_timing 0 41654 NULL
107313 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
107314 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107315 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107316 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
107317 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107318 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
107319 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
107320 +fillonedir_41746 fillonedir 3 41746 NULL
107321 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107322 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107323 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107324 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
107325 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107326 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107327 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107328 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107329 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107330 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107331 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
107332 +get_packet_41914 get_packet 3 41914 NULL
107333 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107334 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107335 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107336 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107337 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107338 +read_gssp_41947 read_gssp 3 41947 NULL
107339 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107340 +portnames_read_41958 portnames_read 3 41958 NULL
107341 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
107342 +dst_mtu_41969 dst_mtu 0 41969 NULL
107343 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107344 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107345 +lguest_map_42008 lguest_map 1-2 42008 NULL
107346 +pool_allocate_42012 pool_allocate 3 42012 NULL
107347 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107348 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107349 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107350 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107351 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107352 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107353 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107354 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107355 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107356 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107357 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107358 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107359 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107360 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107361 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
107362 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107363 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107364 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
107365 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107366 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107367 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
107368 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107369 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
107370 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
107371 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107372 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107373 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107374 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107375 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
107376 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
107377 +free_cblock_42318 free_cblock 2 42318 NULL
107378 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107379 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
107380 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107381 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107382 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107383 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107384 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107385 +krng_get_random_42420 krng_get_random 3 42420 NULL
107386 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107387 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107388 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107389 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107390 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107391 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107392 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107393 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107394 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107395 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
107396 +bypass_write_42498 bypass_write 3 42498 NULL
107397 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107398 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107399 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
107400 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107401 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
107402 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
107403 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107404 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107405 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
107406 +map_state_42602 map_state 1 42602 NULL nohasharray
107407 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
107408 +nd_get_link_42603 nd_get_link 0 42603 NULL
107409 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
107410 +resp_write_42628 resp_write 2 42628 NULL
107411 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
107412 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
107413 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
107414 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
107415 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
107416 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
107417 +vb2_read_42703 vb2_read 3 42703 NULL
107418 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
107419 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
107420 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
107421 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
107422 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
107423 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
107424 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
107425 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
107426 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
107427 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
107428 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
107429 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
107430 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
107431 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
107432 +set_arg_42824 set_arg 3 42824 NULL
107433 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
107434 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
107435 +prandom_u32_42853 prandom_u32 0 42853 NULL
107436 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
107437 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
107438 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
107439 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
107440 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
107441 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
107442 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
107443 +hd_end_request_42904 hd_end_request 2 42904 NULL
107444 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
107445 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
107446 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
107447 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
107448 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
107449 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
107450 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
107451 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
107452 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
107453 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
107454 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
107455 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
107456 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
107457 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
107458 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
107459 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
107460 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
107461 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
107462 +uuid_string_43154 uuid_string 0 43154 NULL
107463 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
107464 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
107465 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
107466 +process_measurement_43190 process_measurement 0 43190 NULL
107467 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
107468 +uio_write_43202 uio_write 3 43202 NULL
107469 +iso_callback_43208 iso_callback 3 43208 NULL
107470 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
107471 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
107472 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
107473 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
107474 +fixup_leb_43256 fixup_leb 3 43256 NULL
107475 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
107476 +evtchn_write_43278 evtchn_write 3 43278 NULL
107477 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
107478 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
107479 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
107480 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
107481 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
107482 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
107483 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
107484 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
107485 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
107486 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
107487 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
107488 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
107489 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
107490 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
107491 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
107492 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
107493 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
107494 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
107495 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
107496 +do_readlink_43518 do_readlink 2 43518 NULL
107497 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
107498 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
107499 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
107500 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
107501 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
107502 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
107503 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
107504 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
107505 +proc_read_43614 proc_read 3 43614 NULL
107506 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
107507 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
107508 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
107509 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
107510 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
107511 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
107512 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
107513 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
107514 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
107515 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
107516 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
107517 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
107518 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
107519 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
107520 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
107521 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
107522 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
107523 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
107524 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
107525 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
107526 +read_flush_43851 read_flush 3 43851 NULL
107527 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
107528 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
107529 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
107530 +SendString_43928 SendString 3 43928 NULL
107531 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
107532 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
107533 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
107534 +nla_reserve_43984 nla_reserve 3 43984 NULL
107535 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
107536 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
107537 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
107538 +emit_flags_44006 emit_flags 4-3 44006 NULL
107539 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
107540 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
107541 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
107542 +load_discard_44083 load_discard 3 44083 NULL
107543 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
107544 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
107545 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
107546 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
107547 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
107548 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
107549 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
107550 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
107551 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
107552 +__set_free_44211 __set_free 2 44211 NULL
107553 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
107554 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
107555 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
107556 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
107557 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
107558 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
107559 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
107560 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
107561 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
107562 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
107563 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
107564 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
107565 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
107566 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
107567 +__is_discarded_44359 __is_discarded 2 44359 NULL
107568 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
107569 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
107570 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
107571 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
107572 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
107573 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
107574 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
107575 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
107576 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
107577 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
107578 +bio_advance_44496 bio_advance 2 44496 NULL
107579 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
107580 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
107581 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
107582 +spidev_write_44510 spidev_write 3 44510 NULL
107583 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
107584 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
107585 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
107586 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
107587 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
107588 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
107589 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
107590 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
107591 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
107592 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
107593 +mpi_resize_44674 mpi_resize 2 44674 NULL
107594 +ts_read_44687 ts_read 3 44687 NULL
107595 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
107596 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
107597 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
107598 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
107599 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
107600 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
107601 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
107602 +set_brk_44749 set_brk 1 44749 NULL
107603 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
107604 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
107605 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
107606 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
107607 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
107608 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
107609 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
107610 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
107611 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
107612 +sisusb_write_44834 sisusb_write 3 44834 NULL
107613 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
107614 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
107615 +cubic_root_44848 cubic_root 1 44848 NULL
107616 +copydesc_user_44855 copydesc_user 3 44855 NULL
107617 +skb_availroom_44883 skb_availroom 0 44883 NULL
107618 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
107619 +do_tty_write_44896 do_tty_write 5 44896 NULL
107620 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
107621 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
107622 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
107623 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
107624 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
107625 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
107626 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
107627 +sel_write_user_45060 sel_write_user 3 45060 NULL
107628 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
107629 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
107630 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
107631 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
107632 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
107633 +usbdev_read_45114 usbdev_read 3 45114 NULL
107634 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
107635 +send_to_tty_45141 send_to_tty 3 45141 NULL
107636 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
107637 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
107638 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
107639 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
107640 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
107641 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
107642 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
107643 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
107644 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
107645 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
107646 +add_child_45201 add_child 4 45201 NULL
107647 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
107648 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
107649 +__dirty_45228 __dirty 2 45228 NULL
107650 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
107651 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
107652 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
107653 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
107654 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
107655 +pte_val_45313 pte_val 0 45313 NULL
107656 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
107657 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
107658 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
107659 +keymap_store_45406 keymap_store 4 45406 NULL
107660 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
107661 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
107662 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
107663 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
107664 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
107665 +__node_remap_45458 __node_remap 4 45458 NULL
107666 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
107667 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
107668 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
107669 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
107670 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
107671 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
107672 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
107673 +copy_macs_45534 copy_macs 4 45534 NULL
107674 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
107675 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
107676 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
107677 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
107678 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
107679 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
107680 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
107681 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
107682 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
107683 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
107684 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
107685 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
107686 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
107687 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
107688 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
107689 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
107690 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
107691 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
107692 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
107693 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
107694 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
107695 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
107696 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
107697 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
107698 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
107699 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
107700 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
107701 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
107702 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
107703 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
107704 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
107705 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
107706 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
107707 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
107708 +isdn_write_45863 isdn_write 3 45863 NULL
107709 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
107710 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
107711 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
107712 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
107713 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
107714 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
107715 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
107716 +alloc_mr_45935 alloc_mr 1 45935 NULL
107717 +split_large_page_45941 split_large_page 2 45941 NULL
107718 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
107719 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
107720 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
107721 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
107722 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
107723 +get_free_entries_46030 get_free_entries 1 46030 NULL
107724 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
107725 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
107726 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
107727 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
107728 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
107729 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
107730 +slhc_toss_46066 slhc_toss 0 46066 NULL
107731 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
107732 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
107733 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
107734 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
107735 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
107736 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
107737 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
107738 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
107739 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
107740 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
107741 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
107742 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
107743 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
107744 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
107745 +add_conn_list_46197 add_conn_list 3 46197 NULL
107746 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
107747 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
107748 +dsp_write_46218 dsp_write 2 46218 NULL
107749 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
107750 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
107751 +ReadReg_46277 ReadReg 0 46277 NULL
107752 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
107753 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
107754 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
107755 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
107756 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
107757 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
107758 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
107759 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
107760 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
107761 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
107762 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
107763 +filldir64_46469 filldir64 3 46469 NULL
107764 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
107765 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
107766 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
107767 +kmsg_read_46514 kmsg_read 3 46514 NULL
107768 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
107769 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
107770 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
107771 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
107772 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
107773 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
107774 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
107775 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
107776 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
107777 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
107778 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
107779 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
107780 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
107781 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
107782 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
107783 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
107784 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
107785 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
107786 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
107787 +prepare_copy_46725 prepare_copy 2 46725 NULL
107788 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
107789 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
107790 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
107791 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
107792 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
107793 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
107794 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
107795 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
107796 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
107797 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
107798 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
107799 +spi_async_46857 spi_async 0 46857 NULL
107800 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
107801 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
107802 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
107803 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
107804 +rvmalloc_46873 rvmalloc 1 46873 NULL
107805 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
107806 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
107807 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
107808 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
107809 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
107810 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
107811 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
107812 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
107813 +fb_write_46924 fb_write 3 46924 NULL
107814 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
107815 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
107816 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
107817 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
107818 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
107819 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
107820 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
107821 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
107822 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
107823 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
107824 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
107825 +__map_single_47020 __map_single 3-4-7 47020 NULL
107826 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
107827 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
107828 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
107829 +fs_path_len_47060 fs_path_len 0 47060 NULL
107830 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
107831 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
107832 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
107833 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
107834 +mousedev_read_47123 mousedev_read 3 47123 NULL
107835 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
107836 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
107837 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
107838 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
107839 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
107840 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
107841 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
107842 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
107843 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
107844 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
107845 +l2headersize_47238 l2headersize 0 47238 NULL
107846 +options_write_47243 options_write 3 47243 NULL
107847 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
107848 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
107849 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
107850 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
107851 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
107852 +vsnprintf_47291 vsnprintf 0 47291 NULL
107853 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
107854 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
107855 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
107856 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
107857 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
107858 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
107859 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
107860 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
107861 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
107862 +nametbl_list_47391 nametbl_list 2 47391 NULL
107863 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
107864 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
107865 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
107866 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
107867 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
107868 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
107869 +vzalloc_47421 vzalloc 1 47421 NULL
107870 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
107871 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
107872 +__load_mapping_47460 __load_mapping 2 47460 NULL
107873 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
107874 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
107875 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
107876 +core_sys_select_47494 core_sys_select 1 47494 NULL
107877 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
107878 +unlink_simple_47506 unlink_simple 3 47506 NULL
107879 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
107880 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
107881 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
107882 +oz_events_read_47535 oz_events_read 3 47535 NULL
107883 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
107884 +read_ldt_47570 read_ldt 2 47570 NULL
107885 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
107886 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
107887 +pci_iomap_47575 pci_iomap 3 47575 NULL
107888 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
107889 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
107890 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
107891 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
107892 +uea_request_47613 uea_request 4 47613 NULL
107893 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
107894 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
107895 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
107896 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
107897 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
107898 +save_microcode_47717 save_microcode 3 47717 NULL
107899 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
107900 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
107901 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
107902 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
107903 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
107904 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
107905 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
107906 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
107907 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
107908 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
107909 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
107910 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
107911 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
107912 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
107913 +vhci_read_47878 vhci_read 3 47878 NULL
107914 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
107915 +load_mapping_47904 load_mapping 3 47904 NULL
107916 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
107917 +comedi_write_47926 comedi_write 3 47926 NULL
107918 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
107919 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
107920 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
107921 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
107922 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
107923 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
107924 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
107925 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
107926 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
107927 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
107928 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
107929 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
107930 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
107931 +disc_write_48070 disc_write 3 48070 NULL
107932 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
107933 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
107934 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
107935 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
107936 +set_discoverable_48141 set_discoverable 4 48141 NULL
107937 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
107938 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
107939 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
107940 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
107941 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
107942 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
107943 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
107944 +init_ipath_48187 init_ipath 1 48187 NULL
107945 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
107946 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
107947 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
107948 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
107949 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
107950 +read_file_recv_48232 read_file_recv 3 48232 NULL
107951 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
107952 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
107953 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
107954 +send_set_info_48288 send_set_info 7 48288 NULL
107955 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
107956 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
107957 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
107958 +hash_setkey_48310 hash_setkey 3 48310 NULL
107959 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
107960 +skb_add_data_48363 skb_add_data 3 48363 NULL
107961 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
107962 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
107963 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
107964 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
107965 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
107966 +print_filtered_48442 print_filtered 2-0 48442 NULL
107967 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
107968 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
107969 +send_control_msg_48498 send_control_msg 6 48498 NULL
107970 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
107971 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
107972 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
107973 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
107974 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
107975 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
107976 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
107977 +named_distribute_48544 named_distribute 4 48544 NULL
107978 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
107979 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
107980 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
107981 +mtd_read_48655 mtd_read 0 48655 NULL
107982 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
107983 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
107984 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
107985 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
107986 +altera_drscan_48698 altera_drscan 2 48698 NULL
107987 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
107988 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
107989 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
107990 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
107991 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
107992 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
107993 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
107994 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
107995 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
107996 +azx_get_position_48841 azx_get_position 0 48841 NULL
107997 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
107998 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
107999 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
108000 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
108001 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
108002 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
108003 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
108004 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
108005 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
108006 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
108007 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
108008 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
108009 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
108010 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
108011 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
108012 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
108013 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
108014 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
108015 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
108016 +transient_status_49027 transient_status 4 49027 NULL
108017 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
108018 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
108019 +ubi_read_49061 ubi_read 0 49061 NULL
108020 +scsi_register_49094 scsi_register 2 49094 NULL
108021 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
108022 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
108023 +check_exists_49119 check_exists 2 49119 NULL nohasharray
108024 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
108025 +pt_read_49136 pt_read 3 49136 NULL
108026 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
108027 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
108028 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
108029 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
108030 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
108031 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
108032 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
108033 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
108034 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
108035 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
108036 +resp_write_same_49217 resp_write_same 2 49217 NULL
108037 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
108038 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
108039 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
108040 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
108041 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
108042 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
108043 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
108044 +uio_read_49300 uio_read 3 49300 NULL
108045 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
108046 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
108047 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
108048 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
108049 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
108050 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
108051 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
108052 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
108053 +px_raw_event_49371 px_raw_event 4 49371 NULL
108054 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
108055 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
108056 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
108057 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
108058 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
108059 +md_domain_init_49432 md_domain_init 2 49432 NULL
108060 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
108061 +get_lru_size_49441 get_lru_size 0 49441 NULL
108062 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
108063 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
108064 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
108065 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
108066 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
108067 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
108068 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
108069 +smk_write_access_49561 smk_write_access 3 49561 NULL
108070 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
108071 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
108072 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
108073 +tap_write_49595 tap_write 3 49595 NULL
108074 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
108075 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
108076 +heap_init_49617 heap_init 2 49617 NULL
108077 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
108078 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
108079 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
108080 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
108081 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
108082 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
108083 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
108084 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
108085 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
108086 +check_frame_49741 check_frame 0 49741 NULL
108087 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
108088 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
108089 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
108090 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
108091 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
108092 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
108093 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
108094 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
108095 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
108096 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
108097 +add_uuid_49831 add_uuid 4 49831 NULL
108098 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
108099 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
108100 +twl4030_write_49846 twl4030_write 2 49846 NULL
108101 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
108102 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
108103 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
108104 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
108105 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
108106 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
108107 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
108108 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
108109 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
108110 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
108111 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
108112 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
108113 +__module_alloc_50004 __module_alloc 1 50004 NULL
108114 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
108115 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
108116 +isdn_read_50021 isdn_read 3 50021 NULL
108117 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
108118 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
108119 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
108120 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
108121 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
108122 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
108123 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
108124 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
108125 +read_file_slot_50111 read_file_slot 3 50111 NULL
108126 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
108127 +copy_items_50140 copy_items 6 50140 NULL
108128 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
108129 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
108130 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
108131 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
108132 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
108133 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
108134 +odev_update_50169 odev_update 2 50169 NULL
108135 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
108136 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
108137 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
108138 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
108139 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
108140 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
108141 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
108142 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
108143 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
108144 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108145 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
108146 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108147 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108148 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108149 +do_launder_page_50329 do_launder_page 0 50329 NULL
108150 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108151 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108152 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108153 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108154 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
108155 +tpm_read_50344 tpm_read 3 50344 NULL
108156 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108157 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108158 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108159 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
108160 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108161 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108162 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108163 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108164 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108165 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
108166 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108167 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108168 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
108169 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108170 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108171 +force_mapping_50464 force_mapping 2 50464 NULL
108172 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108173 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108174 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108175 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
108176 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108177 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
108178 +fat_readpages_50582 fat_readpages 4 50582 NULL
108179 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108180 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108181 +sge_rx_50594 sge_rx 3 50594 NULL
108182 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108183 +__ffs_50625 __ffs 0 50625 NULL
108184 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108185 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108186 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
108187 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
108188 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108189 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
108190 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
108191 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
108192 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108193 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108194 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108195 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108196 +skb_padto_50759 skb_padto 2 50759 NULL
108197 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108198 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108199 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
108200 +tpm_write_50798 tpm_write 3 50798 NULL
108201 +write_flush_50803 write_flush 3 50803 NULL
108202 +dvb_play_50814 dvb_play 3 50814 NULL
108203 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108204 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108205 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108206 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
108207 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
108208 +self_check_write_50856 self_check_write 5 50856 NULL
108209 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108210 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108211 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108212 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
108213 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108214 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108215 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108216 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
108217 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
108218 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
108219 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
108220 +timeout_write_50991 timeout_write 3 50991 NULL
108221 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
108222 +proc_write_51003 proc_write 3 51003 NULL
108223 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
108224 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
108225 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
108226 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
108227 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
108228 +dump_midi_51040 dump_midi 3 51040 NULL
108229 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
108230 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
108231 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
108232 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
108233 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
108234 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
108235 +ti_recv_51110 ti_recv 3 51110 NULL
108236 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
108237 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
108238 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
108239 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
108240 +set_dirty_51144 set_dirty 3 51144 NULL
108241 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
108242 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
108243 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
108244 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
108245 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
108246 +tipc_send_51238 tipc_send 4 51238 NULL
108247 +drm_property_create_51239 drm_property_create 4 51239 NULL
108248 +st_read_51251 st_read 3 51251 NULL
108249 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
108250 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
108251 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
108252 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
108253 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
108254 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
108255 +get_cell_51316 get_cell 2 51316 NULL
108256 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
108257 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
108258 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
108259 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
108260 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
108261 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
108262 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
108263 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
108264 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
108265 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
108266 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
108267 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
108268 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
108269 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
108270 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
108271 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
108272 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
108273 +vaddr_51480 vaddr 0 51480 NULL
108274 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
108275 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
108276 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
108277 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
108278 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
108279 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
108280 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
108281 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
108282 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
108283 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
108284 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
108285 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
108286 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
108287 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
108288 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
108289 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
108290 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
108291 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
108292 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
108293 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
108294 +sel_write_access_51704 sel_write_access 3 51704 NULL
108295 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
108296 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
108297 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
108298 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
108299 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
108300 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
108301 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
108302 +if_write_51756 if_write 3 51756 NULL
108303 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
108304 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
108305 +to_ratio_51809 to_ratio 2-1 51809 NULL
108306 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
108307 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
108308 +ioread32_51847 ioread32 0 51847 NULL nohasharray
108309 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
108310 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
108311 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
108312 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
108313 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
108314 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
108315 +user_read_51881 user_read 3 51881 NULL
108316 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
108317 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
108318 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
108319 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
108320 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
108321 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
108322 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
108323 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
108324 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
108325 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
108326 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
108327 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
108328 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
108329 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
108330 +rdmalt_52022 rdmalt 0 52022 NULL
108331 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
108332 +override_release_52032 override_release 2 52032 NULL
108333 +end_port_52042 end_port 0 52042 NULL
108334 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
108335 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
108336 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
108337 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
108338 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
108339 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
108340 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
108341 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
108342 +retry_count_read_52129 retry_count_read 3 52129 NULL
108343 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
108344 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
108345 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
108346 +htable_size_52148 htable_size 0-1 52148 NULL
108347 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
108348 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
108349 +alix_present_52165 alix_present 1 52165 NULL
108350 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
108351 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
108352 +print_prefix_52176 print_prefix 0 52176 NULL
108353 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
108354 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
108355 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
108356 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
108357 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
108358 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
108359 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
108360 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
108361 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
108362 +atomic64_read_52300 atomic64_read 0 52300 NULL
108363 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
108364 +read_file_reset_52310 read_file_reset 3 52310 NULL
108365 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
108366 +hwflags_read_52318 hwflags_read 3 52318 NULL
108367 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
108368 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
108369 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
108370 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
108371 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
108372 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
108373 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
108374 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
108375 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
108376 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
108377 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
108378 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
108379 +delay_status_52431 delay_status 5 52431 NULL
108380 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
108381 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
108382 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
108383 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
108384 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
108385 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
108386 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
108387 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
108388 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
108389 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
108390 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
108391 +from_oblock_52546 from_oblock 0-1 52546 NULL
108392 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
108393 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
108394 +emit_code_52583 emit_code 0-3 52583 NULL
108395 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
108396 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
108397 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
108398 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
108399 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
108400 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
108401 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
108402 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
108403 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
108404 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
108405 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
108406 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
108407 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
108408 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
108409 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
108410 +twlreg_write_52880 twlreg_write 3 52880 NULL
108411 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
108412 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
108413 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
108414 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
108415 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
108416 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
108417 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
108418 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
108419 +send_packet_52960 send_packet 4 52960 NULL
108420 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
108421 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
108422 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
108423 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
108424 +num_node_state_52989 num_node_state 0 52989 NULL
108425 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
108426 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
108427 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
108428 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
108429 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
108430 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
108431 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
108432 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
108433 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
108434 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
108435 +verity_status_53120 verity_status 5 53120 NULL
108436 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
108437 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
108438 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
108439 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
108440 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
108441 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
108442 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
108443 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
108444 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
108445 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
108446 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
108447 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
108448 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
108449 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
108450 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
108451 +vm_mmap_53339 vm_mmap 0 53339 NULL
108452 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
108453 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
108454 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
108455 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
108456 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
108457 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
108458 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
108459 +n2_run_53459 n2_run 3 53459 NULL
108460 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
108461 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
108462 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
108463 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
108464 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
108465 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
108466 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
108467 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
108468 +check_acl_53512 check_acl 0 53512 NULL
108469 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
108470 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
108471 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
108472 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
108473 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
108474 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
108475 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
108476 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
108477 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
108478 +_preload_range_53676 _preload_range 2-3 53676 NULL
108479 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
108480 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
108481 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
108482 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
108483 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
108484 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
108485 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
108486 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
108487 +wdm_write_53735 wdm_write 3 53735 NULL
108488 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
108489 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
108490 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
108491 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
108492 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
108493 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
108494 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
108495 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
108496 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
108497 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
108498 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
108499 +pms_read_53873 pms_read 3 53873 NULL
108500 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
108501 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
108502 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
108503 +proc_file_read_53905 proc_file_read 3 53905 NULL
108504 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
108505 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
108506 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
108507 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
108508 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
108509 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
108510 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
108511 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
108512 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
108513 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
108514 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
108515 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
108516 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
108517 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
108518 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
108519 +_malloc_54077 _malloc 1 54077 NULL
108520 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
108521 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
108522 +create_xattr_54106 create_xattr 5 54106 NULL
108523 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
108524 +strn_len_54122 strn_len 0 54122 NULL
108525 +isku_receive_54130 isku_receive 4 54130 NULL
108526 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
108527 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
108528 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
108529 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
108530 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
108531 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
108532 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
108533 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
108534 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
108535 +reada_add_block_54247 reada_add_block 2 54247 NULL
108536 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
108537 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
108538 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
108539 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
108540 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
108541 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
108542 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
108543 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
108544 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
108545 +sprintf_54306 sprintf 0 54306 NULL
108546 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
108547 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
108548 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
108549 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
108550 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
108551 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
108552 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
108553 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
108554 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
108555 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
108556 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
108557 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
108558 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
108559 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
108560 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
108561 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
108562 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
108563 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
108564 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
108565 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
108566 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
108567 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
108568 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
108569 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
108570 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
108571 +viacam_read_54526 viacam_read 3 54526 NULL
108572 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
108573 +setsockopt_54539 setsockopt 5 54539 NULL
108574 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
108575 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
108576 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
108577 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
108578 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
108579 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
108580 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
108581 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
108582 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
108583 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
108584 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
108585 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
108586 +evm_read_key_54674 evm_read_key 3 54674 NULL
108587 +resource_string_54699 resource_string 0 54699 NULL
108588 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
108589 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
108590 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
108591 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
108592 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
108593 +kzalloc_54740 kzalloc 1 54740 NULL
108594 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
108595 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
108596 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
108597 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
108598 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
108599 +domain_init_54797 domain_init 2 54797 NULL
108600 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
108601 +get_dev_size_54807 get_dev_size 0 54807 NULL
108602 +nfsd_write_54809 nfsd_write 6 54809 NULL
108603 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
108604 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
108605 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
108606 +write_rio_54837 write_rio 3 54837 NULL
108607 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
108608 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
108609 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
108610 +printer_read_54851 printer_read 3 54851 NULL
108611 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
108612 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
108613 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
108614 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
108615 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
108616 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
108617 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
108618 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
108619 +add_port_54941 add_port 2 54941 NULL
108620 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
108621 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
108622 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
108623 +c4_add_card_54968 c4_add_card 3 54968 NULL
108624 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
108625 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
108626 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
108627 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
108628 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
108629 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
108630 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
108631 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
108632 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
108633 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
108634 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
108635 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
108636 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
108637 +corrupt_data_55120 corrupt_data 0 55120 NULL
108638 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
108639 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
108640 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
108641 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
108642 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
108643 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
108644 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
108645 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
108646 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
108647 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
108648 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
108649 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
108650 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
108651 +dump_command_55220 dump_command 1 55220 NULL
108652 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
108653 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
108654 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
108655 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
108656 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
108657 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
108658 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
108659 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
108660 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
108661 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
108662 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
108663 +do_shmat_55336 do_shmat 5 55336 NULL
108664 +vme_user_read_55338 vme_user_read 3 55338 NULL
108665 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
108666 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
108667 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
108668 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
108669 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
108670 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
108671 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
108672 +alloc_skb_55439 alloc_skb 1 55439 NULL
108673 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
108674 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
108675 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
108676 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
108677 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
108678 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
108679 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
108680 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
108681 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
108682 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
108683 +ea_get_55522 ea_get 0 55522 NULL
108684 +buffer_size_55534 buffer_size 0 55534 NULL
108685 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
108686 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
108687 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
108688 +add_partition_55588 add_partition 2 55588 NULL
108689 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
108690 +free_pages_55603 free_pages 1 55603 NULL
108691 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
108692 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
108693 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
108694 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
108695 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
108696 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
108697 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
108698 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
108699 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
108700 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
108701 +read_oldmem_55658 read_oldmem 3 55658 NULL
108702 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
108703 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
108704 +get_info_55681 get_info 3 55681 NULL
108705 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
108706 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
108707 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
108708 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
108709 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
108710 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
108711 +set_local_name_55757 set_local_name 4 55757 NULL
108712 +strlen_55778 strlen 0 55778 NULL
108713 +set_spte_55783 set_spte 5-4 55783 NULL
108714 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
108715 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
108716 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
108717 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
108718 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
108719 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
108720 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
108721 +hsc_write_55875 hsc_write 3 55875 NULL
108722 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
108723 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
108724 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
108725 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
108726 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
108727 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
108728 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
108729 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
108730 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
108731 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
108732 +__set_discard_56081 __set_discard 2 56081 NULL
108733 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
108734 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
108735 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
108736 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
108737 +map_addr_56144 map_addr 7 56144 NULL
108738 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
108739 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
108740 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
108741 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
108742 +skb_headroom_56200 skb_headroom 0 56200 NULL
108743 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
108744 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
108745 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
108746 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
108747 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
108748 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
108749 +fd_copyin_56247 fd_copyin 3 56247 NULL
108750 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
108751 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
108752 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
108753 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
108754 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
108755 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
108756 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
108757 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
108758 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
108759 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
108760 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
108761 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
108762 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
108763 +dev_read_56369 dev_read 3 56369 NULL
108764 +write_gssp_56404 write_gssp 3 56404 NULL
108765 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
108766 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
108767 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
108768 +store_msg_56417 store_msg 3 56417 NULL
108769 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
108770 +fl_create_56435 fl_create 5 56435 NULL
108771 +gnttab_map_56439 gnttab_map 2 56439 NULL
108772 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
108773 +set_connectable_56458 set_connectable 4 56458 NULL
108774 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
108775 +putused_user_56467 putused_user 3 56467 NULL
108776 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
108777 +global_rt_period_56476 global_rt_period 0 56476 NULL
108778 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
108779 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
108780 +init_map_ip_56508 init_map_ip 5 56508 NULL
108781 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
108782 +ip_options_get_56538 ip_options_get 4 56538 NULL
108783 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
108784 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
108785 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
108786 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
108787 +event_filter_write_56609 event_filter_write 3 56609 NULL
108788 +gather_array_56641 gather_array 3 56641 NULL
108789 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
108790 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
108791 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
108792 +build_map_info_56696 build_map_info 2 56696 NULL
108793 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
108794 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
108795 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
108796 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
108797 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
108798 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
108799 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
108800 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
108801 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
108802 +hash_lookup_56792 hash_lookup 2 56792 NULL
108803 +do_syslog_56807 do_syslog 3 56807 NULL
108804 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
108805 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
108806 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
108807 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
108808 +wb_lookup_56858 wb_lookup 2 56858 NULL
108809 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
108810 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
108811 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
108812 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
108813 +strcspn_56913 strcspn 0 56913 NULL
108814 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
108815 +check_header_56930 check_header 2 56930 NULL
108816 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
108817 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
108818 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
108819 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
108820 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
108821 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
108822 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
108823 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
108824 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
108825 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
108826 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
108827 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
108828 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
108829 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
108830 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
108831 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
108832 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
108833 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
108834 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
108835 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
108836 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
108837 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
108838 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
108839 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
108840 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
108841 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
108842 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
108843 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
108844 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
108845 +flush_space_57241 flush_space 3 57241 NULL
108846 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
108847 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
108848 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
108849 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
108850 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
108851 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
108852 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
108853 +fw_file_size_57307 fw_file_size 0 57307 NULL
108854 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
108855 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
108856 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
108857 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
108858 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
108859 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
108860 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
108861 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
108862 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
108863 +read_file_blob_57406 read_file_blob 3 57406 NULL
108864 +enclosure_register_57412 enclosure_register 3 57412 NULL
108865 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
108866 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
108867 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
108868 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
108869 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
108870 +ReadReg_57453 ReadReg 0 57453 NULL
108871 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
108872 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
108873 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
108874 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
108875 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
108876 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
108877 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
108878 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
108879 +skb_headlen_57501 skb_headlen 0 57501 NULL
108880 +copy_in_user_57502 copy_in_user 3 57502 NULL
108881 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
108882 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
108883 +init_tag_map_57515 init_tag_map 3 57515 NULL
108884 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
108885 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
108886 +inode_permission_57531 inode_permission 0 57531 NULL
108887 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
108888 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
108889 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
108890 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
108891 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
108892 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
108893 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
108894 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
108895 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
108896 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
108897 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
108898 +mem_read_57631 mem_read 3 57631 NULL
108899 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
108900 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
108901 +r3964_write_57662 r3964_write 4 57662 NULL
108902 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
108903 +__lgwrite_57669 __lgwrite 4 57669 NULL
108904 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
108905 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
108906 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
108907 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
108908 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
108909 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
108910 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
108911 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
108912 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
108913 +ld2_57794 ld2 0 57794 NULL
108914 +ivtv_read_57796 ivtv_read 3 57796 NULL
108915 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
108916 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
108917 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
108918 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
108919 +copy_to_user_57835 copy_to_user 3 57835 NULL
108920 +flash_read_57843 flash_read 3 57843 NULL
108921 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
108922 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
108923 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
108924 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
108925 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
108926 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
108927 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
108928 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
108929 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
108930 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
108931 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
108932 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
108933 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
108934 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
108935 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
108936 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
108937 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
108938 +mce_async_out_58056 mce_async_out 3 58056 NULL
108939 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
108940 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
108941 +cm4040_write_58079 cm4040_write 3 58079 NULL
108942 +udi_log_event_58105 udi_log_event 3 58105 NULL
108943 +savemem_58129 savemem 3 58129 NULL
108944 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
108945 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
108946 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
108947 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
108948 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
108949 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
108950 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
108951 +read_file_debug_58256 read_file_debug 3 58256 NULL
108952 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
108953 +profile_load_58267 profile_load 3 58267 NULL
108954 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
108955 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
108956 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
108957 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
108958 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
108959 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
108960 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
108961 +next_pidmap_58347 next_pidmap 2 58347 NULL
108962 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
108963 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
108964 +save_hint_58359 save_hint 2 58359 NULL
108965 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
108966 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
108967 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
108968 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
108969 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
108970 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
108971 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
108972 +capabilities_read_58457 capabilities_read 3 58457 NULL
108973 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
108974 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
108975 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
108976 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
108977 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
108978 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
108979 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
108980 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
108981 +__clear_discard_58546 __clear_discard 2 58546 NULL
108982 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
108983 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
108984 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
108985 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
108986 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
108987 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
108988 +xip_file_read_58592 xip_file_read 3 58592 NULL
108989 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
108990 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
108991 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
108992 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
108993 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
108994 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
108995 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
108996 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
108997 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
108998 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
108999 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
109000 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
109001 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
109002 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
109003 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
109004 +acpi_map_58725 acpi_map 1-2 58725 NULL
109005 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
109006 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
109007 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
109008 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
109009 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
109010 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
109011 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
109012 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
109013 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
109014 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
109015 +ep_read_58813 ep_read 3 58813 NULL
109016 +command_write_58841 command_write 3 58841 NULL
109017 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
109018 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
109019 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
109020 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
109021 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
109022 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
109023 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
109024 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
109025 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
109026 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
109027 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
109028 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
109029 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
109030 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
109031 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
109032 +ep_write_59008 ep_write 3 59008 NULL
109033 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
109034 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
109035 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
109036 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
109037 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
109038 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
109039 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
109040 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
109041 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
109042 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
109043 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
109044 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
109045 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
109046 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
109047 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
109048 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
109049 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
109050 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
109051 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
109052 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
109053 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
109054 +dt3155_read_59226 dt3155_read 3 59226 NULL
109055 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
109056 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
109057 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
109058 +nla_len_59258 nla_len 0 59258 NULL
109059 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
109060 +fd_copyout_59323 fd_copyout 3 59323 NULL
109061 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
109062 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
109063 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
109064 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
109065 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
109066 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
109067 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
109068 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
109069 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
109070 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
109071 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
109072 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
109073 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
109074 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
109075 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
109076 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
109077 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
109078 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
109079 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
109080 +tunables_write_59563 tunables_write 3 59563 NULL
109081 +memdup_user_59590 memdup_user 2 59590 NULL
109082 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
109083 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
109084 +mtrr_write_59622 mtrr_write 3 59622 NULL
109085 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
109086 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
109087 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
109088 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
109089 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
109090 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
109091 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
109092 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
109093 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
109094 +sriov_enable_59689 sriov_enable 2 59689 NULL
109095 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
109096 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
109097 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
109098 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
109099 +strnlen_59746 strnlen 0 59746 NULL
109100 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
109101 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
109102 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
109103 +venus_remove_59781 venus_remove 4 59781 NULL
109104 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
109105 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
109106 +ipw_write_59807 ipw_write 3 59807 NULL
109107 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
109108 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
109109 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
109110 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
109111 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
109112 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
109113 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
109114 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
109115 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
109116 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
109117 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
109118 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
109119 +lookup_node_59953 lookup_node 2 59953 NULL
109120 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
109121 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
109122 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
109123 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
109124 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
109125 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
109126 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
109127 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
109128 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
109129 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
109130 +register_device_60015 register_device 2-3 60015 NULL
109131 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
109132 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
109133 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
109134 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
109135 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
109136 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
109137 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
109138 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
109139 +compat_writev_60063 compat_writev 3 60063 NULL
109140 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
109141 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
109142 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
109143 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
109144 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
109145 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
109146 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
109147 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
109148 +init_state_60165 init_state 2 60165 NULL
109149 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
109150 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
109151 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
109152 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
109153 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
109154 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
109155 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
109156 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
109157 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
109158 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
109159 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
109160 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
109161 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
109162 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
109163 +printer_write_60276 printer_write 3 60276 NULL
109164 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
109165 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
109166 +getDataLength_60301 getDataLength 0 60301 NULL
109167 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
109168 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
109169 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
109170 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
109171 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
109172 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
109173 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
109174 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
109175 +driver_names_read_60399 driver_names_read 3 60399 NULL
109176 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
109177 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
109178 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
109179 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
109180 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
109181 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
109182 +rx_data_60442 rx_data 4 60442 NULL nohasharray
109183 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
109184 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
109185 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
109186 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
109187 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
109188 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
109189 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
109190 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
109191 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
109192 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
109193 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
109194 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
109195 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
109196 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
109197 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
109198 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
109199 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
109200 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
109201 +init_data_container_60709 init_data_container 1 60709 NULL
109202 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
109203 +raid_status_60755 raid_status 5 60755 NULL
109204 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
109205 +opticon_write_60775 opticon_write 4 60775 NULL
109206 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
109207 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
109208 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
109209 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
109210 +generic_writepages_60871 generic_writepages 0 60871 NULL
109211 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
109212 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
109213 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
109214 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
109215 +sys_mlock_60932 sys_mlock 1 60932 NULL
109216 +pti_char_write_60960 pti_char_write 3 60960 NULL
109217 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
109218 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
109219 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
109220 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
109221 +symtab_init_61050 symtab_init 2 61050 NULL
109222 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
109223 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
109224 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
109225 +get_derived_key_61100 get_derived_key 4 61100 NULL
109226 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
109227 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
109228 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
109229 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
109230 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
109231 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
109232 +__vmalloc_61168 __vmalloc 1 61168 NULL
109233 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
109234 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
109235 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
109236 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
109237 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
109238 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
109239 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
109240 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
109241 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
109242 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
109243 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
109244 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
109245 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
109246 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
109247 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
109248 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
109249 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
109250 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
109251 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
109252 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
109253 +change_xattr_61390 change_xattr 5 61390 NULL
109254 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
109255 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
109256 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
109257 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
109258 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
109259 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
109260 +erst_errno_61526 erst_errno 0 61526 NULL
109261 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
109262 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
109263 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
109264 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
109265 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
109266 +seq_open_private_61589 seq_open_private 3 61589 NULL
109267 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
109268 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
109269 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
109270 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
109271 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
109272 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
109273 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
109274 +resize_stripes_61650 resize_stripes 2 61650 NULL
109275 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
109276 +insert_one_name_61668 insert_one_name 7 61668 NULL
109277 +lock_loop_61681 lock_loop 1 61681 NULL
109278 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
109279 +filter_read_61692 filter_read 3 61692 NULL
109280 +iov_length_61716 iov_length 0 61716 NULL
109281 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
109282 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
109283 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
109284 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
109285 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
109286 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
109287 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
109288 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
109289 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
109290 +get_fw_name_61874 get_fw_name 3 61874 NULL
109291 +free_init_pages_61875 free_init_pages 2 61875 NULL
109292 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
109293 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
109294 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
109295 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
109296 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
109297 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
109298 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
109299 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
109300 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
109301 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
109302 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
109303 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
109304 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
109305 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
109306 +cow_file_range_61979 cow_file_range 3 61979 NULL
109307 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
109308 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
109309 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
109310 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
109311 +SYSC_select_62024 SYSC_select 1 62024 NULL
109312 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
109313 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
109314 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
109315 +do_pselect_62061 do_pselect 1 62061 NULL
109316 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
109317 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
109318 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
109319 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
109320 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
109321 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
109322 +ql_status_62135 ql_status 5 62135 NULL
109323 +video_usercopy_62151 video_usercopy 2 62151 NULL
109324 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
109325 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
109326 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
109327 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
109328 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
109329 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
109330 +allocate_partition_62245 allocate_partition 4 62245 NULL
109331 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
109332 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
109333 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
109334 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
109335 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
109336 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
109337 +subseq_list_62332 subseq_list 3-0 62332 NULL
109338 +flash_write_62354 flash_write 3 62354 NULL
109339 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
109340 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
109341 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
109342 +altera_irscan_62396 altera_irscan 2 62396 NULL
109343 +set_ssp_62411 set_ssp 4 62411 NULL
109344 +unmap_single_62423 unmap_single 2 62423 NULL
109345 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
109346 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
109347 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
109348 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
109349 +remove_mapping_62491 remove_mapping 2 62491 NULL
109350 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
109351 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
109352 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
109353 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
109354 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
109355 +debugfs_read_62535 debugfs_read 3 62535 NULL
109356 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
109357 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
109358 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
109359 +get_subdir_62581 get_subdir 3 62581 NULL
109360 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
109361 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
109362 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
109363 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
109364 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
109365 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
109366 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
109367 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
109368 +write_62671 write 3 62671 NULL
109369 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
109370 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
109371 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
109372 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
109373 +rdm_62719 rdm 0 62719 NULL
109374 +key_replays_read_62746 key_replays_read 3 62746 NULL
109375 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
109376 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
109377 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
109378 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
109379 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
109380 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
109381 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
109382 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
109383 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
109384 +set_swbp_62853 set_swbp 3 62853 NULL
109385 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
109386 +aoechr_write_62883 aoechr_write 3 62883 NULL
109387 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
109388 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
109389 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
109390 +getdqbuf_62908 getdqbuf 1 62908 NULL
109391 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
109392 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
109393 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
109394 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
109395 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
109396 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
109397 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
109398 +unlink1_63059 unlink1 3 63059 NULL
109399 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
109400 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
109401 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
109402 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
109403 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
109404 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
109405 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
109406 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
109407 +vme_master_read_63221 vme_master_read 0 63221 NULL
109408 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
109409 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
109410 +ptp_read_63251 ptp_read 4 63251 NULL
109411 +raid5_resize_63306 raid5_resize 2 63306 NULL
109412 +proc_info_read_63344 proc_info_read 3 63344 NULL
109413 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
109414 +idmouse_read_63374 idmouse_read 3 63374 NULL
109415 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
109416 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
109417 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
109418 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
109419 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
109420 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
109421 +kone_send_63435 kone_send 4 63435 NULL
109422 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
109423 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
109424 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
109425 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
109426 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
109427 +read_kcore_63488 read_kcore 3 63488 NULL
109428 +save_hint_63497 save_hint 2 63497 NULL
109429 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
109430 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
109431 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
109432 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
109433 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
109434 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
109435 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
109436 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
109437 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
109438 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
109439 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
109440 +module_alloc_63630 module_alloc 1 63630 NULL
109441 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
109442 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
109443 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
109444 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
109445 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
109446 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
109447 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
109448 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
109449 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
109450 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
109451 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
109452 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
109453 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
109454 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
109455 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
109456 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
109457 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
109458 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
109459 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
109460 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
109461 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
109462 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
109463 +prepare_copy_63826 prepare_copy 2 63826 NULL
109464 +sel_write_load_63830 sel_write_load 3 63830 NULL
109465 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
109466 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
109467 +divas_write_63901 divas_write 3 63901 NULL
109468 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
109469 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
109470 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
109471 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
109472 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
109473 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
109474 +__team_options_register_63941 __team_options_register 3 63941 NULL
109475 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
109476 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
109477 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
109478 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
109479 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
109480 +kmemdup_64015 kmemdup 2 64015 NULL
109481 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
109482 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
109483 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
109484 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
109485 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
109486 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
109487 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
109488 +get_u8_64076 get_u8 0 64076 NULL
109489 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
109490 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
109491 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
109492 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
109493 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
109494 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
109495 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
109496 +init_bch_64130 init_bch 1-2 64130 NULL
109497 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
109498 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
109499 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
109500 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
109501 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
109502 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
109503 +read_pulse_64227 read_pulse 0-3 64227 NULL
109504 +header_len_64232 header_len 0 64232 NULL
109505 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
109506 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
109507 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
109508 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
109509 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
109510 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
109511 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
109512 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
109513 +ffz_64324 ffz 0 64324 NULL
109514 +map_region_64328 map_region 1 64328 NULL
109515 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
109516 +ts_write_64336 ts_write 3 64336 NULL
109517 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
109518 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
109519 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
109520 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
109521 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
109522 +ilo_write_64378 ilo_write 3 64378 NULL
109523 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
109524 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
109525 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
109526 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
109527 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
109528 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
109529 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
109530 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
109531 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
109532 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
109533 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
109534 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
109535 +cap_capable_64462 cap_capable 0 64462 NULL
109536 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
109537 +single_open_size_64483 single_open_size 4 64483 NULL
109538 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
109539 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
109540 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
109541 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
109542 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
109543 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
109544 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
109545 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
109546 +SyS_bind_64544 SyS_bind 3 64544 NULL
109547 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
109548 +__spi_sync_64561 __spi_sync 0 64561 NULL
109549 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
109550 +fanotify_write_64623 fanotify_write 3 64623 NULL
109551 +to_dblock_64655 to_dblock 0-1 64655 NULL
109552 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
109553 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
109554 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
109555 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
109556 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
109557 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
109558 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
109559 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
109560 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
109561 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
109562 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
109563 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
109564 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
109565 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
109566 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
109567 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
109568 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
109569 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
109570 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
109571 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
109572 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
109573 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
109574 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
109575 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
109576 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
109577 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
109578 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
109579 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
109580 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
109581 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
109582 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
109583 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
109584 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
109585 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
109586 +pskb_pull_65005 pskb_pull 2 65005 NULL
109587 +unifi_write_65012 unifi_write 3 65012 NULL
109588 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
109589 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
109590 +insert_dent_65034 insert_dent 7 65034 NULL
109591 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
109592 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
109593 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
109594 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
109595 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
109596 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
109597 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
109598 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
109599 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
109600 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
109601 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
109602 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
109603 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
109604 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
109605 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
109606 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
109607 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
109608 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
109609 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
109610 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
109611 +get_var_len_65304 get_var_len 0 65304 NULL
109612 +unpack_array_65318 unpack_array 0 65318 NULL
109613 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
109614 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
109615 +init_list_set_65351 init_list_set 2-3 65351 NULL
109616 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
109617 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
109618 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
109619 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
109620 +strchr_65372 strchr 0 65372 NULL nohasharray
109621 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
109622 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
109623 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
109624 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
109625 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
109626 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
109627 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
109628 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
109629 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
109630 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
109631 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
109632 +alloc_dr_65495 alloc_dr 2 65495 NULL
109633 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
109634 new file mode 100644
109635 index 0000000..03d0c84
109636 --- /dev/null
109637 +++ b/tools/gcc/size_overflow_plugin.c
109638 @@ -0,0 +1,2113 @@
109639 +/*
109640 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
109641 + * Licensed under the GPL v2, or (at your option) v3
109642 + *
109643 + * Homepage:
109644 + * http://www.grsecurity.net/~ephox/overflow_plugin/
109645 + *
109646 + * Documentation:
109647 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
109648 + *
109649 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
109650 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
109651 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
109652 + *
109653 + * Usage:
109654 + * $ 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
109655 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
109656 + */
109657 +
109658 +#include "gcc-plugin.h"
109659 +#include "config.h"
109660 +#include "system.h"
109661 +#include "coretypes.h"
109662 +#include "tree.h"
109663 +#include "tree-pass.h"
109664 +#include "intl.h"
109665 +#include "plugin-version.h"
109666 +#include "tm.h"
109667 +#include "toplev.h"
109668 +#include "function.h"
109669 +#include "tree-flow.h"
109670 +#include "plugin.h"
109671 +#include "gimple.h"
109672 +#include "diagnostic.h"
109673 +#include "cfgloop.h"
109674 +
109675 +#if BUILDING_GCC_VERSION >= 4008
109676 +#define TODO_dump_func 0
109677 +#endif
109678 +
109679 +struct size_overflow_hash {
109680 + const struct size_overflow_hash * const next;
109681 + const char * const name;
109682 + const unsigned int param;
109683 +};
109684 +
109685 +#include "size_overflow_hash.h"
109686 +
109687 +enum mark {
109688 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
109689 +};
109690 +
109691 +enum err_code_conditions {
109692 + CAST_ONLY, FROM_CONST
109693 +};
109694 +
109695 +static unsigned int call_count = 0;
109696 +
109697 +#define __unused __attribute__((__unused__))
109698 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
109699 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
109700 +#define BEFORE_STMT true
109701 +#define AFTER_STMT false
109702 +#define CREATE_NEW_VAR NULL_TREE
109703 +#define CODES_LIMIT 32
109704 +#define MAX_PARAM 31
109705 +#define MY_STMT GF_PLF_1
109706 +#define NO_CAST_CHECK GF_PLF_2
109707 +#define FROM_ARG true
109708 +#define FROM_RET false
109709 +
109710 +#if BUILDING_GCC_VERSION == 4005
109711 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
109712 +#endif
109713 +
109714 +int plugin_is_GPL_compatible;
109715 +void debug_gimple_stmt(gimple gs);
109716 +
109717 +static tree expand(struct pointer_set_t *visited, tree lhs);
109718 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
109719 +static tree report_size_overflow_decl;
109720 +static const_tree const_char_ptr_type_node;
109721 +static unsigned int handle_function(void);
109722 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
109723 +static tree get_size_overflow_type(gimple stmt, const_tree node);
109724 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
109725 +static void print_missing_msg(tree func, unsigned int argnum);
109726 +
109727 +static struct plugin_info size_overflow_plugin_info = {
109728 + .version = "20130822beta",
109729 + .help = "no-size-overflow\tturn off size overflow checking\n",
109730 +};
109731 +
109732 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
109733 +{
109734 + unsigned int arg_count;
109735 + enum tree_code code = TREE_CODE(*node);
109736 +
109737 + switch (code) {
109738 + case FUNCTION_DECL:
109739 + arg_count = type_num_arguments(TREE_TYPE(*node));
109740 + break;
109741 + case FUNCTION_TYPE:
109742 + case METHOD_TYPE:
109743 + arg_count = type_num_arguments(*node);
109744 + break;
109745 + default:
109746 + *no_add_attrs = true;
109747 + error("%s: %qE attribute only applies to functions", __func__, name);
109748 + return NULL_TREE;
109749 + }
109750 +
109751 + for (; args; args = TREE_CHAIN(args)) {
109752 + tree position = TREE_VALUE(args);
109753 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
109754 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
109755 + *no_add_attrs = true;
109756 + }
109757 + }
109758 + return NULL_TREE;
109759 +}
109760 +
109761 +static const char* get_asm_name(tree node)
109762 +{
109763 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
109764 +}
109765 +
109766 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
109767 +{
109768 + unsigned int arg_count, arg_num;
109769 + enum tree_code code = TREE_CODE(*node);
109770 +
109771 + switch (code) {
109772 + case FUNCTION_DECL:
109773 + arg_count = type_num_arguments(TREE_TYPE(*node));
109774 + break;
109775 + case FUNCTION_TYPE:
109776 + case METHOD_TYPE:
109777 + arg_count = type_num_arguments(*node);
109778 + break;
109779 + case FIELD_DECL:
109780 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
109781 + if (arg_num != 0) {
109782 + *no_add_attrs = true;
109783 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
109784 + }
109785 + return NULL_TREE;
109786 + default:
109787 + *no_add_attrs = true;
109788 + error("%qE attribute only applies to functions", name);
109789 + return NULL_TREE;
109790 + }
109791 +
109792 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
109793 + return NULL_TREE;
109794 +
109795 + for (; args; args = TREE_CHAIN(args)) {
109796 + tree position = TREE_VALUE(args);
109797 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
109798 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
109799 + *no_add_attrs = true;
109800 + }
109801 + }
109802 + return NULL_TREE;
109803 +}
109804 +
109805 +static struct attribute_spec size_overflow_attr = {
109806 + .name = "size_overflow",
109807 + .min_length = 1,
109808 + .max_length = -1,
109809 + .decl_required = true,
109810 + .type_required = false,
109811 + .function_type_required = false,
109812 + .handler = handle_size_overflow_attribute,
109813 +#if BUILDING_GCC_VERSION >= 4007
109814 + .affects_type_identity = false
109815 +#endif
109816 +};
109817 +
109818 +static struct attribute_spec intentional_overflow_attr = {
109819 + .name = "intentional_overflow",
109820 + .min_length = 1,
109821 + .max_length = -1,
109822 + .decl_required = true,
109823 + .type_required = false,
109824 + .function_type_required = false,
109825 + .handler = handle_intentional_overflow_attribute,
109826 +#if BUILDING_GCC_VERSION >= 4007
109827 + .affects_type_identity = false
109828 +#endif
109829 +};
109830 +
109831 +static void register_attributes(void __unused *event_data, void __unused *data)
109832 +{
109833 + register_attribute(&size_overflow_attr);
109834 + register_attribute(&intentional_overflow_attr);
109835 +}
109836 +
109837 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
109838 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
109839 +{
109840 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
109841 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
109842 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
109843 +
109844 + unsigned int m = 0x57559429;
109845 + unsigned int n = 0x5052acdb;
109846 + const unsigned int *key4 = (const unsigned int *)key;
109847 + unsigned int h = len;
109848 + unsigned int k = len + seed + n;
109849 + unsigned long long p;
109850 +
109851 + while (len >= 8) {
109852 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
109853 + len -= 8;
109854 + }
109855 + if (len >= 4) {
109856 + cwmixb(key4[0]) key4 += 1;
109857 + len -= 4;
109858 + }
109859 + if (len)
109860 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
109861 + cwmixb(h ^ (k + n));
109862 + return k ^ h;
109863 +
109864 +#undef cwfold
109865 +#undef cwmixa
109866 +#undef cwmixb
109867 +}
109868 +
109869 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
109870 +{
109871 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
109872 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
109873 + return fn ^ codes;
109874 +}
109875 +
109876 +static inline tree get_original_function_decl(tree fndecl)
109877 +{
109878 + if (DECL_ABSTRACT_ORIGIN(fndecl))
109879 + return DECL_ABSTRACT_ORIGIN(fndecl);
109880 + return fndecl;
109881 +}
109882 +
109883 +static inline gimple get_def_stmt(const_tree node)
109884 +{
109885 + gcc_assert(node != NULL_TREE);
109886 + if (TREE_CODE(node) != SSA_NAME)
109887 + return NULL;
109888 + return SSA_NAME_DEF_STMT(node);
109889 +}
109890 +
109891 +static unsigned char get_tree_code(const_tree type)
109892 +{
109893 + switch (TREE_CODE(type)) {
109894 + case ARRAY_TYPE:
109895 + return 0;
109896 + case BOOLEAN_TYPE:
109897 + return 1;
109898 + case ENUMERAL_TYPE:
109899 + return 2;
109900 + case FUNCTION_TYPE:
109901 + return 3;
109902 + case INTEGER_TYPE:
109903 + return 4;
109904 + case POINTER_TYPE:
109905 + return 5;
109906 + case RECORD_TYPE:
109907 + return 6;
109908 + case UNION_TYPE:
109909 + return 7;
109910 + case VOID_TYPE:
109911 + return 8;
109912 + case REAL_TYPE:
109913 + return 9;
109914 + case VECTOR_TYPE:
109915 + return 10;
109916 + case REFERENCE_TYPE:
109917 + return 11;
109918 + case OFFSET_TYPE:
109919 + return 12;
109920 + case COMPLEX_TYPE:
109921 + return 13;
109922 + default:
109923 + debug_tree((tree)type);
109924 + gcc_unreachable();
109925 + }
109926 +}
109927 +
109928 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
109929 +{
109930 + gcc_assert(type != NULL_TREE);
109931 +
109932 + while (type && len < CODES_LIMIT) {
109933 + tree_codes[len] = get_tree_code(type);
109934 + len++;
109935 + type = TREE_TYPE(type);
109936 + }
109937 + return len;
109938 +}
109939 +
109940 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
109941 +{
109942 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
109943 + enum tree_code code = TREE_CODE(type);
109944 + size_t len = 0;
109945 +
109946 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
109947 +
109948 + arg = TYPE_ARG_TYPES(type);
109949 + // skip builtins __builtin_constant_p
109950 + if (!arg && DECL_BUILT_IN(fndecl))
109951 + return 0;
109952 +
109953 + if (TREE_CODE_CLASS(code) == tcc_type)
109954 + result = type;
109955 + else
109956 + result = DECL_RESULT(fndecl);
109957 +
109958 + gcc_assert(result != NULL_TREE);
109959 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
109960 +
109961 + if (arg == NULL_TREE) {
109962 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
109963 + arg_field = DECL_ARGUMENT_FLD(fndecl);
109964 + if (arg_field == NULL_TREE)
109965 + return 0;
109966 + arg = TREE_TYPE(arg_field);
109967 + len = add_type_codes(arg, tree_codes, len);
109968 + gcc_assert(len != 0);
109969 + return len;
109970 + }
109971 +
109972 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
109973 + while (arg && len < CODES_LIMIT) {
109974 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
109975 + arg = TREE_CHAIN(arg);
109976 + }
109977 +
109978 + gcc_assert(len != 0);
109979 + return len;
109980 +}
109981 +
109982 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
109983 +{
109984 + unsigned int hash;
109985 + const struct size_overflow_hash *entry;
109986 + unsigned char tree_codes[CODES_LIMIT];
109987 + size_t len;
109988 + const char *func_name;
109989 +
109990 + fndecl = get_original_function_decl(fndecl);
109991 + len = get_function_decl(fndecl, tree_codes);
109992 + if (len == 0)
109993 + return NULL;
109994 +
109995 + func_name = get_asm_name(fndecl);
109996 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
109997 +
109998 + entry = size_overflow_hash[hash];
109999 + while (entry) {
110000 + if (!strcmp(entry->name, func_name))
110001 + return entry;
110002 + entry = entry->next;
110003 + }
110004 +
110005 + return NULL;
110006 +}
110007 +
110008 +static bool is_bool(const_tree node)
110009 +{
110010 + const_tree type;
110011 +
110012 + if (node == NULL_TREE)
110013 + return false;
110014 +
110015 + type = TREE_TYPE(node);
110016 + if (!INTEGRAL_TYPE_P(type))
110017 + return false;
110018 + if (TREE_CODE(type) == BOOLEAN_TYPE)
110019 + return true;
110020 + if (TYPE_PRECISION(type) == 1)
110021 + return true;
110022 + return false;
110023 +}
110024 +
110025 +static bool skip_types(const_tree var)
110026 +{
110027 + tree type;
110028 +
110029 + if (is_gimple_constant(var))
110030 + return true;
110031 +
110032 + switch (TREE_CODE(var)) {
110033 + case ADDR_EXPR:
110034 +#if BUILDING_GCC_VERSION >= 4006
110035 + case MEM_REF:
110036 +#endif
110037 + case ARRAY_REF:
110038 + case BIT_FIELD_REF:
110039 + case INDIRECT_REF:
110040 + case TARGET_MEM_REF:
110041 + return true;
110042 + case PARM_DECL:
110043 + case VAR_DECL:
110044 + case COMPONENT_REF:
110045 + return false;
110046 + default:
110047 + break;
110048 + }
110049 +
110050 + gcc_assert(TREE_CODE(var) == SSA_NAME);
110051 +
110052 + type = TREE_TYPE(var);
110053 + switch (TREE_CODE(type)) {
110054 + case INTEGER_TYPE:
110055 + case ENUMERAL_TYPE:
110056 + return false;
110057 + case BOOLEAN_TYPE:
110058 + return is_bool(var);
110059 + default:
110060 + break;
110061 + }
110062 +
110063 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
110064 +
110065 + type = TREE_TYPE(type);
110066 + gcc_assert(type != NULL_TREE);
110067 + switch (TREE_CODE(type)) {
110068 + case RECORD_TYPE:
110069 + case POINTER_TYPE:
110070 + case ARRAY_TYPE:
110071 + return true;
110072 + case VOID_TYPE:
110073 + case INTEGER_TYPE:
110074 + case UNION_TYPE:
110075 + return false;
110076 + default:
110077 + break;
110078 + }
110079 +
110080 + debug_tree((tree)var);
110081 + gcc_unreachable();
110082 +}
110083 +
110084 +static unsigned int find_arg_number(const_tree arg, tree func)
110085 +{
110086 + tree var;
110087 + unsigned int argnum = 1;
110088 +
110089 + if (TREE_CODE(arg) == SSA_NAME)
110090 + arg = SSA_NAME_VAR(arg);
110091 +
110092 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
110093 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
110094 + continue;
110095 + if (!skip_types(var))
110096 + return argnum;
110097 + }
110098 +
110099 + return 0;
110100 +}
110101 +
110102 +static tree create_new_var(tree type)
110103 +{
110104 + tree new_var = create_tmp_var(type, "cicus");
110105 +
110106 +#if BUILDING_GCC_VERSION <= 4007
110107 + add_referenced_var(new_var);
110108 +#endif
110109 + return new_var;
110110 +}
110111 +
110112 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
110113 +{
110114 + gimple assign;
110115 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110116 + tree type = TREE_TYPE(rhs1);
110117 + tree lhs = create_new_var(type);
110118 +
110119 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
110120 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
110121 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
110122 +
110123 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
110124 + update_stmt(assign);
110125 + gimple_set_plf(assign, MY_STMT, true);
110126 + return assign;
110127 +}
110128 +
110129 +static tree cast_a_tree(tree type, tree var)
110130 +{
110131 + gcc_assert(type != NULL_TREE);
110132 + gcc_assert(var != NULL_TREE);
110133 + gcc_assert(fold_convertible_p(type, var));
110134 +
110135 + return fold_convert(type, var);
110136 +}
110137 +
110138 +static tree get_lhs(const_gimple stmt)
110139 +{
110140 + switch (gimple_code(stmt)) {
110141 + case GIMPLE_ASSIGN:
110142 + return gimple_get_lhs(stmt);
110143 + case GIMPLE_PHI:
110144 + return gimple_phi_result(stmt);
110145 + case GIMPLE_CALL:
110146 + return gimple_call_lhs(stmt);
110147 + default:
110148 + return NULL_TREE;
110149 + }
110150 +}
110151 +
110152 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
110153 +{
110154 + const_gimple def_stmt = get_def_stmt(rhs);
110155 +
110156 + if (force)
110157 + return false;
110158 +
110159 + if (is_gimple_constant(rhs))
110160 + return false;
110161 +
110162 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110163 + return false;
110164 +
110165 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
110166 + return false;
110167 +
110168 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
110169 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110170 + return false;
110171 +
110172 + return true;
110173 +}
110174 +
110175 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
110176 +{
110177 + gimple assign, def_stmt;
110178 +
110179 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
110180 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
110181 + gcc_unreachable();
110182 +
110183 + def_stmt = get_def_stmt(rhs);
110184 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
110185 + return def_stmt;
110186 +
110187 + if (lhs == CREATE_NEW_VAR)
110188 + lhs = create_new_var(dst_type);
110189 +
110190 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
110191 +
110192 + if (!gsi_end_p(*gsi)) {
110193 + location_t loc = gimple_location(gsi_stmt(*gsi));
110194 + gimple_set_location(assign, loc);
110195 + }
110196 +
110197 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
110198 +
110199 + if (before)
110200 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
110201 + else
110202 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
110203 + update_stmt(assign);
110204 + gimple_set_plf(assign, MY_STMT, true);
110205 +
110206 + return assign;
110207 +}
110208 +
110209 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
110210 +{
110211 + gimple_stmt_iterator gsi;
110212 + tree lhs;
110213 + const_gimple new_stmt;
110214 +
110215 + if (rhs == NULL_TREE)
110216 + return NULL_TREE;
110217 +
110218 + gsi = gsi_for_stmt(stmt);
110219 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110220 +
110221 + lhs = get_lhs(new_stmt);
110222 + gcc_assert(lhs != NULL_TREE);
110223 + return lhs;
110224 +}
110225 +
110226 +static tree cast_to_TI_type(gimple stmt, tree node)
110227 +{
110228 + gimple_stmt_iterator gsi;
110229 + gimple cast_stmt;
110230 + tree type = TREE_TYPE(node);
110231 +
110232 + if (types_compatible_p(type, intTI_type_node))
110233 + return node;
110234 +
110235 + gsi = gsi_for_stmt(stmt);
110236 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110237 + return gimple_get_lhs(cast_stmt);
110238 +}
110239 +
110240 +static void check_function_hash(const_gimple stmt)
110241 +{
110242 + tree func;
110243 + const struct size_overflow_hash *hash;
110244 +
110245 + if (gimple_code(stmt) != GIMPLE_CALL)
110246 + return;
110247 +
110248 + func = gimple_call_fndecl(stmt);
110249 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
110250 + if (func == NULL_TREE)
110251 + return;
110252 +
110253 + hash = get_function_hash(func);
110254 + if (!hash)
110255 + print_missing_msg(func, 0);
110256 +}
110257 +
110258 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
110259 +{
110260 + tree lhs, new_lhs;
110261 + gimple_stmt_iterator gsi;
110262 +
110263 + if (rhs1 == NULL_TREE) {
110264 + debug_gimple_stmt(oldstmt);
110265 + error("%s: rhs1 is NULL_TREE", __func__);
110266 + gcc_unreachable();
110267 + }
110268 +
110269 + switch (gimple_code(oldstmt)) {
110270 + case GIMPLE_ASM:
110271 + lhs = rhs1;
110272 + break;
110273 + case GIMPLE_CALL:
110274 + lhs = gimple_call_lhs(oldstmt);
110275 + break;
110276 + case GIMPLE_ASSIGN:
110277 + lhs = gimple_get_lhs(oldstmt);
110278 + break;
110279 + default:
110280 + debug_gimple_stmt(oldstmt);
110281 + gcc_unreachable();
110282 + }
110283 +
110284 + gsi = gsi_for_stmt(oldstmt);
110285 + pointer_set_insert(visited, oldstmt);
110286 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
110287 + basic_block next_bb, cur_bb;
110288 + const_edge e;
110289 +
110290 + gcc_assert(before == false);
110291 + gcc_assert(stmt_can_throw_internal(oldstmt));
110292 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
110293 + gcc_assert(!gsi_end_p(gsi));
110294 +
110295 + cur_bb = gimple_bb(oldstmt);
110296 + next_bb = cur_bb->next_bb;
110297 + e = find_edge(cur_bb, next_bb);
110298 + gcc_assert(e != NULL);
110299 + gcc_assert(e->flags & EDGE_FALLTHRU);
110300 +
110301 + gsi = gsi_after_labels(next_bb);
110302 + gcc_assert(!gsi_end_p(gsi));
110303 +
110304 + before = true;
110305 + oldstmt = gsi_stmt(gsi);
110306 + }
110307 +
110308 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
110309 + return new_lhs;
110310 +}
110311 +
110312 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
110313 +{
110314 + gimple stmt;
110315 + gimple_stmt_iterator gsi;
110316 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
110317 +
110318 + if (gimple_plf(oldstmt, MY_STMT))
110319 + return lhs;
110320 +
110321 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
110322 + rhs1 = gimple_assign_rhs1(oldstmt);
110323 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
110324 + }
110325 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
110326 + rhs2 = gimple_assign_rhs2(oldstmt);
110327 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
110328 + }
110329 +
110330 + stmt = gimple_copy(oldstmt);
110331 + gimple_set_location(stmt, gimple_location(oldstmt));
110332 + gimple_set_plf(stmt, MY_STMT, true);
110333 +
110334 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
110335 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
110336 +
110337 + size_overflow_type = get_size_overflow_type(oldstmt, node);
110338 +
110339 + new_var = create_new_var(size_overflow_type);
110340 + new_var = make_ssa_name(new_var, stmt);
110341 + gimple_set_lhs(stmt, new_var);
110342 +
110343 + if (rhs1 != NULL_TREE)
110344 + gimple_assign_set_rhs1(stmt, rhs1);
110345 +
110346 + if (rhs2 != NULL_TREE)
110347 + gimple_assign_set_rhs2(stmt, rhs2);
110348 +#if BUILDING_GCC_VERSION >= 4007
110349 + if (rhs3 != NULL_TREE)
110350 + gimple_assign_set_rhs3(stmt, rhs3);
110351 +#endif
110352 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
110353 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
110354 +
110355 + gsi = gsi_for_stmt(oldstmt);
110356 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
110357 + update_stmt(stmt);
110358 + pointer_set_insert(visited, oldstmt);
110359 + return gimple_get_lhs(stmt);
110360 +}
110361 +
110362 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
110363 +{
110364 + basic_block first_bb;
110365 + gimple assign;
110366 + gimple_stmt_iterator gsi;
110367 +
110368 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110369 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110370 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
110371 +
110372 + gsi = gsi_start_bb(first_bb);
110373 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110374 + return gimple_get_lhs(assign);
110375 +}
110376 +
110377 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
110378 +{
110379 + gimple_stmt_iterator gsi;
110380 + const_gimple assign;
110381 + gimple def_stmt = get_def_stmt(new_arg);
110382 +
110383 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
110384 + gsi = gsi_after_labels(gimple_bb(def_stmt));
110385 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
110386 + } else {
110387 + gsi = gsi_for_stmt(def_stmt);
110388 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
110389 + }
110390 +
110391 + return gimple_get_lhs(assign);
110392 +}
110393 +
110394 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
110395 +{
110396 + basic_block bb;
110397 + gimple_stmt_iterator gsi;
110398 + const_gimple assign, def_stmt;
110399 +
110400 + def_stmt = get_def_stmt(arg);
110401 + bb = gimple_bb(def_stmt);
110402 + gcc_assert(bb->index != 0);
110403 + gsi = gsi_after_labels(bb);
110404 +
110405 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110406 + return gimple_get_lhs(assign);
110407 +}
110408 +
110409 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
110410 +{
110411 + tree size_overflow_type;
110412 + const_gimple def_stmt = get_def_stmt(arg);
110413 +
110414 + if (phi_ssa_name != NULL_TREE)
110415 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
110416 +
110417 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
110418 +
110419 + if (new_arg != NULL_TREE) {
110420 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
110421 + return use_phi_ssa_name(phi_ssa_name, new_arg);
110422 + }
110423 +
110424 + switch(gimple_code(def_stmt)) {
110425 + case GIMPLE_PHI:
110426 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
110427 + case GIMPLE_NOP:
110428 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
110429 + default:
110430 + debug_gimple_stmt((gimple)def_stmt);
110431 + gcc_unreachable();
110432 + }
110433 +}
110434 +
110435 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
110436 +{
110437 + basic_block bb;
110438 + gimple phi;
110439 + gimple_seq seq;
110440 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
110441 +
110442 + bb = gsi_bb(gsi);
110443 +
110444 + phi = create_phi_node(result, bb);
110445 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
110446 + seq = phi_nodes(bb);
110447 + gsi = gsi_last(seq);
110448 + gsi_remove(&gsi, false);
110449 +
110450 + gsi = gsi_for_stmt(oldstmt);
110451 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
110452 + gimple_set_bb(phi, bb);
110453 + gimple_set_plf(phi, MY_STMT, true);
110454 + return phi;
110455 +}
110456 +
110457 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
110458 +{
110459 + gimple new_phi = NULL;
110460 + gimple oldstmt = get_def_stmt(orig_result);
110461 + tree phi_ssa_name = NULL_TREE;
110462 + unsigned int i;
110463 +
110464 + pointer_set_insert(visited, oldstmt);
110465 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
110466 + tree arg, new_arg;
110467 +
110468 + arg = gimple_phi_arg_def(oldstmt, i);
110469 +
110470 + new_arg = expand(visited, arg);
110471 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
110472 + if (i == 0) {
110473 + phi_ssa_name = new_arg;
110474 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
110475 + }
110476 +
110477 + gcc_assert(new_phi != NULL);
110478 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
110479 + }
110480 +
110481 + gcc_assert(new_phi != NULL);
110482 + update_stmt(new_phi);
110483 + return gimple_phi_result(new_phi);
110484 +}
110485 +
110486 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
110487 +{
110488 + const_gimple assign;
110489 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110490 + tree origtype = TREE_TYPE(orig_rhs);
110491 +
110492 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
110493 +
110494 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110495 + return gimple_get_lhs(assign);
110496 +}
110497 +
110498 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
110499 +{
110500 + const_tree rhs1, lhs, rhs1_type, lhs_type;
110501 + enum machine_mode lhs_mode, rhs_mode;
110502 + gimple def_stmt = get_def_stmt(no_const_rhs);
110503 +
110504 + if (!gimple_assign_cast_p(def_stmt))
110505 + return false;
110506 +
110507 + rhs1 = gimple_assign_rhs1(def_stmt);
110508 + lhs = gimple_get_lhs(def_stmt);
110509 + rhs1_type = TREE_TYPE(rhs1);
110510 + lhs_type = TREE_TYPE(lhs);
110511 + rhs_mode = TYPE_MODE(rhs1_type);
110512 + lhs_mode = TYPE_MODE(lhs_type);
110513 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
110514 + return false;
110515 +
110516 + return true;
110517 +}
110518 +
110519 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
110520 +{
110521 + tree rhs1 = gimple_assign_rhs1(stmt);
110522 + tree lhs = gimple_get_lhs(stmt);
110523 + const_tree rhs1_type = TREE_TYPE(rhs1);
110524 + const_tree lhs_type = TREE_TYPE(lhs);
110525 +
110526 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
110527 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110528 +
110529 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
110530 +}
110531 +
110532 +static bool no_uses(tree node)
110533 +{
110534 + imm_use_iterator imm_iter;
110535 + use_operand_p use_p;
110536 +
110537 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
110538 + const_gimple use_stmt = USE_STMT(use_p);
110539 + if (use_stmt == NULL)
110540 + return true;
110541 + if (is_gimple_debug(use_stmt))
110542 + continue;
110543 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
110544 + continue;
110545 + return false;
110546 + }
110547 + return true;
110548 +}
110549 +
110550 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
110551 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
110552 +{
110553 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
110554 + gimple def_stmt = get_def_stmt(lhs);
110555 +
110556 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110557 + return false;
110558 +
110559 + rhs1 = gimple_assign_rhs1(def_stmt);
110560 + rhs_type = TREE_TYPE(rhs1);
110561 + lhs_type = TREE_TYPE(lhs);
110562 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
110563 + return false;
110564 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
110565 + return false;
110566 +
110567 + def_stmt = get_def_stmt(rhs1);
110568 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
110569 + return false;
110570 +
110571 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
110572 + return false;
110573 +
110574 + rhs1 = gimple_assign_rhs1(def_stmt);
110575 + rhs2 = gimple_assign_rhs2(def_stmt);
110576 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
110577 + return false;
110578 +
110579 + if (is_gimple_constant(rhs2))
110580 + not_const_rhs = rhs1;
110581 + else
110582 + not_const_rhs = rhs2;
110583 +
110584 + return no_uses(not_const_rhs);
110585 +}
110586 +
110587 +static bool skip_lhs_cast_check(const_gimple stmt)
110588 +{
110589 + const_tree rhs = gimple_assign_rhs1(stmt);
110590 + const_gimple def_stmt = get_def_stmt(rhs);
110591 +
110592 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
110593 + if (gimple_code(def_stmt) == GIMPLE_ASM)
110594 + return true;
110595 +
110596 + if (is_const_plus_unsigned_signed_truncation(rhs))
110597 + return true;
110598 +
110599 + return false;
110600 +}
110601 +
110602 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
110603 +{
110604 + bool cast_lhs, cast_rhs;
110605 + tree lhs = gimple_get_lhs(stmt);
110606 + tree rhs = gimple_assign_rhs1(stmt);
110607 + const_tree lhs_type = TREE_TYPE(lhs);
110608 + const_tree rhs_type = TREE_TYPE(rhs);
110609 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
110610 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
110611 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
110612 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
110613 +
110614 + static bool check_lhs[3][4] = {
110615 + // ss su us uu
110616 + { false, true, true, false }, // lhs > rhs
110617 + { false, false, false, false }, // lhs = rhs
110618 + { true, true, true, true }, // lhs < rhs
110619 + };
110620 +
110621 + static bool check_rhs[3][4] = {
110622 + // ss su us uu
110623 + { true, false, true, true }, // lhs > rhs
110624 + { true, false, true, true }, // lhs = rhs
110625 + { true, false, true, true }, // lhs < rhs
110626 + };
110627 +
110628 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
110629 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
110630 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110631 +
110632 + if (lhs_size > rhs_size) {
110633 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110634 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110635 + } else if (lhs_size == rhs_size) {
110636 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110637 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110638 + } else {
110639 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110640 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110641 + }
110642 +
110643 + if (!cast_lhs && !cast_rhs)
110644 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110645 +
110646 + if (cast_lhs && !skip_lhs_cast_check(stmt))
110647 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
110648 +
110649 + if (cast_rhs)
110650 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
110651 +
110652 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110653 +}
110654 +
110655 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
110656 +{
110657 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
110658 +
110659 + if (gimple_plf(stmt, MY_STMT))
110660 + return lhs;
110661 +
110662 + rhs1 = gimple_assign_rhs1(stmt);
110663 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
110664 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110665 +
110666 + new_rhs1 = expand(visited, rhs1);
110667 +
110668 + if (new_rhs1 == NULL_TREE)
110669 + return create_cast_assign(visited, stmt);
110670 +
110671 + if (gimple_plf(stmt, NO_CAST_CHECK))
110672 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110673 +
110674 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
110675 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
110676 +
110677 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
110678 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
110679 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110680 + }
110681 +
110682 + if (!gimple_assign_cast_p(stmt))
110683 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110684 +
110685 + return create_cast_overflow_check(visited, new_rhs1, stmt);
110686 +}
110687 +
110688 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
110689 +{
110690 + tree rhs1, lhs = gimple_get_lhs(stmt);
110691 + gimple def_stmt = get_def_stmt(lhs);
110692 +
110693 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
110694 + rhs1 = gimple_assign_rhs1(def_stmt);
110695 +
110696 + if (is_gimple_constant(rhs1))
110697 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110698 +
110699 + switch (TREE_CODE(rhs1)) {
110700 + case SSA_NAME:
110701 + return handle_unary_rhs(visited, def_stmt);
110702 + case ARRAY_REF:
110703 + case BIT_FIELD_REF:
110704 + case ADDR_EXPR:
110705 + case COMPONENT_REF:
110706 + case INDIRECT_REF:
110707 +#if BUILDING_GCC_VERSION >= 4006
110708 + case MEM_REF:
110709 +#endif
110710 + case TARGET_MEM_REF:
110711 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110712 + case PARM_DECL:
110713 + case VAR_DECL:
110714 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110715 +
110716 + default:
110717 + debug_gimple_stmt(def_stmt);
110718 + debug_tree(rhs1);
110719 + gcc_unreachable();
110720 + }
110721 +}
110722 +
110723 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
110724 +{
110725 + gimple cond_stmt;
110726 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
110727 +
110728 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
110729 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
110730 + update_stmt(cond_stmt);
110731 +}
110732 +
110733 +static tree create_string_param(tree string)
110734 +{
110735 + tree i_type, a_type;
110736 + const int length = TREE_STRING_LENGTH(string);
110737 +
110738 + gcc_assert(length > 0);
110739 +
110740 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
110741 + a_type = build_array_type(char_type_node, i_type);
110742 +
110743 + TREE_TYPE(string) = a_type;
110744 + TREE_CONSTANT(string) = 1;
110745 + TREE_READONLY(string) = 1;
110746 +
110747 + return build1(ADDR_EXPR, ptr_type_node, string);
110748 +}
110749 +
110750 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
110751 +{
110752 + gimple func_stmt;
110753 + const_gimple def_stmt;
110754 + const_tree loc_line;
110755 + tree loc_file, ssa_name, current_func;
110756 + expanded_location xloc;
110757 + char *ssa_name_buf;
110758 + int len;
110759 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
110760 +
110761 + def_stmt = get_def_stmt(arg);
110762 + xloc = expand_location(gimple_location(def_stmt));
110763 +
110764 + if (!gimple_has_location(def_stmt)) {
110765 + xloc = expand_location(gimple_location(stmt));
110766 + if (!gimple_has_location(stmt))
110767 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
110768 + }
110769 +
110770 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
110771 +
110772 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
110773 + loc_file = create_string_param(loc_file);
110774 +
110775 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
110776 + current_func = create_string_param(current_func);
110777 +
110778 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
110779 + call_count++;
110780 + 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);
110781 + gcc_assert(len > 0);
110782 + ssa_name = build_string(len + 1, ssa_name_buf);
110783 + free(ssa_name_buf);
110784 + ssa_name = create_string_param(ssa_name);
110785 +
110786 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
110787 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
110788 +
110789 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
110790 +}
110791 +
110792 +static void __unused print_the_code_insertions(const_gimple stmt)
110793 +{
110794 + location_t loc = gimple_location(stmt);
110795 +
110796 + inform(loc, "Integer size_overflow check applied here.");
110797 +}
110798 +
110799 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
110800 +{
110801 + basic_block cond_bb, join_bb, bb_true;
110802 + edge e;
110803 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110804 +
110805 + cond_bb = gimple_bb(stmt);
110806 + if (before)
110807 + gsi_prev(&gsi);
110808 + if (gsi_end_p(gsi))
110809 + e = split_block_after_labels(cond_bb);
110810 + else
110811 + e = split_block(cond_bb, gsi_stmt(gsi));
110812 + cond_bb = e->src;
110813 + join_bb = e->dest;
110814 + e->flags = EDGE_FALSE_VALUE;
110815 + e->probability = REG_BR_PROB_BASE;
110816 +
110817 + bb_true = create_empty_bb(cond_bb);
110818 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
110819 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
110820 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
110821 +
110822 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110823 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
110824 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
110825 +
110826 + if (current_loops != NULL) {
110827 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
110828 + add_bb_to_loop(bb_true, cond_bb->loop_father);
110829 + }
110830 +
110831 + insert_cond(cond_bb, arg, cond_code, type_value);
110832 + insert_cond_result(bb_true, stmt, arg, min);
110833 +
110834 +// print_the_code_insertions(stmt);
110835 +}
110836 +
110837 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
110838 +{
110839 + const_tree rhs_type = TREE_TYPE(rhs);
110840 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
110841 +
110842 + gcc_assert(rhs_type != NULL_TREE);
110843 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
110844 + return;
110845 +
110846 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
110847 +
110848 + if (is_const_plus_unsigned_signed_truncation(rhs))
110849 + return;
110850 +
110851 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
110852 + // typemax (-1) < typemin (0)
110853 + if (TREE_OVERFLOW(type_max))
110854 + return;
110855 +
110856 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
110857 +
110858 + cast_rhs_type = TREE_TYPE(cast_rhs);
110859 + type_max_type = TREE_TYPE(type_max);
110860 + type_min_type = TREE_TYPE(type_min);
110861 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
110862 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
110863 +
110864 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
110865 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
110866 +}
110867 +
110868 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
110869 +{
110870 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
110871 + return false;
110872 + if (!is_gimple_constant(rhs))
110873 + return false;
110874 + return true;
110875 +}
110876 +
110877 +static tree get_def_stmt_rhs(const_tree var)
110878 +{
110879 + tree rhs1, def_stmt_rhs1;
110880 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
110881 +
110882 + def_stmt = get_def_stmt(var);
110883 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
110884 +
110885 + rhs1 = gimple_assign_rhs1(def_stmt);
110886 + rhs1_def_stmt = get_def_stmt(rhs1);
110887 + if (!gimple_assign_cast_p(rhs1_def_stmt))
110888 + return rhs1;
110889 +
110890 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
110891 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
110892 +
110893 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
110894 + case GIMPLE_CALL:
110895 + case GIMPLE_NOP:
110896 + case GIMPLE_ASM:
110897 + case GIMPLE_PHI:
110898 + return def_stmt_rhs1;
110899 + case GIMPLE_ASSIGN:
110900 + return rhs1;
110901 + default:
110902 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
110903 + gcc_unreachable();
110904 + }
110905 +}
110906 +
110907 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
110908 +{
110909 + tree new_rhs, orig_rhs;
110910 + void (*gimple_assign_set_rhs)(gimple, tree);
110911 + tree rhs1 = gimple_assign_rhs1(stmt);
110912 + tree rhs2 = gimple_assign_rhs2(stmt);
110913 + tree lhs = gimple_get_lhs(stmt);
110914 +
110915 + if (!check_overflow)
110916 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110917 +
110918 + if (change_rhs == NULL_TREE)
110919 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110920 +
110921 + if (new_rhs2 == NULL_TREE) {
110922 + orig_rhs = rhs1;
110923 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
110924 + } else {
110925 + orig_rhs = rhs2;
110926 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
110927 + }
110928 +
110929 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
110930 +
110931 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
110932 + gimple_assign_set_rhs(stmt, new_rhs);
110933 + update_stmt(stmt);
110934 +
110935 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110936 +}
110937 +
110938 +static bool is_subtraction_special(const_gimple stmt)
110939 +{
110940 + gimple rhs1_def_stmt, rhs2_def_stmt;
110941 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
110942 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
110943 + const_tree rhs1 = gimple_assign_rhs1(stmt);
110944 + const_tree rhs2 = gimple_assign_rhs2(stmt);
110945 +
110946 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
110947 + return false;
110948 +
110949 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
110950 +
110951 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
110952 + return false;
110953 +
110954 + rhs1_def_stmt = get_def_stmt(rhs1);
110955 + rhs2_def_stmt = get_def_stmt(rhs2);
110956 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
110957 + return false;
110958 +
110959 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
110960 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
110961 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
110962 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
110963 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
110964 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
110965 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
110966 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
110967 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
110968 + return false;
110969 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
110970 + return false;
110971 +
110972 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
110973 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
110974 + return true;
110975 +}
110976 +
110977 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
110978 +{
110979 + tree new_rhs1, new_rhs2;
110980 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
110981 + gimple assign, stmt = get_def_stmt(lhs);
110982 + tree rhs1 = gimple_assign_rhs1(stmt);
110983 + tree rhs2 = gimple_assign_rhs2(stmt);
110984 +
110985 + if (!is_subtraction_special(stmt))
110986 + return NULL_TREE;
110987 +
110988 + new_rhs1 = expand(visited, rhs1);
110989 + new_rhs2 = expand(visited, rhs2);
110990 +
110991 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
110992 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
110993 +
110994 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
110995 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
110996 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
110997 + }
110998 +
110999 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
111000 + new_lhs = gimple_get_lhs(assign);
111001 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
111002 +
111003 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111004 +}
111005 +
111006 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
111007 +{
111008 + const_gimple def_stmt;
111009 +
111010 + if (TREE_CODE(rhs) != SSA_NAME)
111011 + return false;
111012 +
111013 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
111014 + return false;
111015 +
111016 + def_stmt = get_def_stmt(rhs);
111017 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
111018 + return false;
111019 +
111020 + return true;
111021 +}
111022 +
111023 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
111024 +{
111025 + tree rhs1, rhs2, new_lhs;
111026 + gimple def_stmt = get_def_stmt(lhs);
111027 + tree new_rhs1 = NULL_TREE;
111028 + tree new_rhs2 = NULL_TREE;
111029 +
111030 + rhs1 = gimple_assign_rhs1(def_stmt);
111031 + rhs2 = gimple_assign_rhs2(def_stmt);
111032 +
111033 + /* no DImode/TImode division in the 32/64 bit kernel */
111034 + switch (gimple_assign_rhs_code(def_stmt)) {
111035 + case RDIV_EXPR:
111036 + case TRUNC_DIV_EXPR:
111037 + case CEIL_DIV_EXPR:
111038 + case FLOOR_DIV_EXPR:
111039 + case ROUND_DIV_EXPR:
111040 + case TRUNC_MOD_EXPR:
111041 + case CEIL_MOD_EXPR:
111042 + case FLOOR_MOD_EXPR:
111043 + case ROUND_MOD_EXPR:
111044 + case EXACT_DIV_EXPR:
111045 + case POINTER_PLUS_EXPR:
111046 + case BIT_AND_EXPR:
111047 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111048 + default:
111049 + break;
111050 + }
111051 +
111052 + new_lhs = handle_integer_truncation(visited, lhs);
111053 + if (new_lhs != NULL_TREE)
111054 + return new_lhs;
111055 +
111056 + if (TREE_CODE(rhs1) == SSA_NAME)
111057 + new_rhs1 = expand(visited, rhs1);
111058 + if (TREE_CODE(rhs2) == SSA_NAME)
111059 + new_rhs2 = expand(visited, rhs2);
111060 +
111061 + if (is_a_neg_overflow(def_stmt, rhs2))
111062 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
111063 + if (is_a_neg_overflow(def_stmt, rhs1))
111064 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
111065 +
111066 +
111067 + if (is_a_constant_overflow(def_stmt, rhs2))
111068 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
111069 + if (is_a_constant_overflow(def_stmt, rhs1))
111070 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
111071 +
111072 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111073 +}
111074 +
111075 +#if BUILDING_GCC_VERSION >= 4007
111076 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
111077 +{
111078 + if (is_gimple_constant(rhs))
111079 + return cast_a_tree(size_overflow_type, rhs);
111080 + if (TREE_CODE(rhs) != SSA_NAME)
111081 + return NULL_TREE;
111082 + return expand(visited, rhs);
111083 +}
111084 +
111085 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
111086 +{
111087 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
111088 + gimple def_stmt = get_def_stmt(lhs);
111089 +
111090 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
111091 +
111092 + rhs1 = gimple_assign_rhs1(def_stmt);
111093 + rhs2 = gimple_assign_rhs2(def_stmt);
111094 + rhs3 = gimple_assign_rhs3(def_stmt);
111095 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
111096 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
111097 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
111098 +
111099 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
111100 +}
111101 +#endif
111102 +
111103 +static tree get_size_overflow_type(gimple stmt, const_tree node)
111104 +{
111105 + const_tree type;
111106 + tree new_type;
111107 +
111108 + gcc_assert(node != NULL_TREE);
111109 +
111110 + type = TREE_TYPE(node);
111111 +
111112 + if (gimple_plf(stmt, MY_STMT))
111113 + return TREE_TYPE(node);
111114 +
111115 + switch (TYPE_MODE(type)) {
111116 + case QImode:
111117 + new_type = intHI_type_node;
111118 + break;
111119 + case HImode:
111120 + new_type = intSI_type_node;
111121 + break;
111122 + case SImode:
111123 + new_type = intDI_type_node;
111124 + break;
111125 + case DImode:
111126 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111127 + new_type = intDI_type_node;
111128 + else
111129 + new_type = intTI_type_node;
111130 + break;
111131 + default:
111132 + debug_tree((tree)node);
111133 + error("%s: unsupported gcc configuration.", __func__);
111134 + gcc_unreachable();
111135 + }
111136 +
111137 + if (TYPE_QUALS(type) != 0)
111138 + return build_qualified_type(new_type, TYPE_QUALS(type));
111139 + return new_type;
111140 +}
111141 +
111142 +static tree expand_visited(gimple def_stmt)
111143 +{
111144 + const_gimple next_stmt;
111145 + gimple_stmt_iterator gsi;
111146 + enum gimple_code code = gimple_code(def_stmt);
111147 +
111148 + if (code == GIMPLE_ASM)
111149 + return NULL_TREE;
111150 +
111151 + gsi = gsi_for_stmt(def_stmt);
111152 + gsi_next(&gsi);
111153 +
111154 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111155 + return NULL_TREE;
111156 + gcc_assert(!gsi_end_p(gsi));
111157 + next_stmt = gsi_stmt(gsi);
111158 +
111159 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
111160 + return NULL_TREE;
111161 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
111162 +
111163 + return get_lhs(next_stmt);
111164 +}
111165 +
111166 +static tree expand(struct pointer_set_t *visited, tree lhs)
111167 +{
111168 + gimple def_stmt;
111169 +
111170 + if (skip_types(lhs))
111171 + return NULL_TREE;
111172 +
111173 + def_stmt = get_def_stmt(lhs);
111174 +
111175 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111176 + return NULL_TREE;
111177 +
111178 + if (gimple_plf(def_stmt, MY_STMT))
111179 + return lhs;
111180 +
111181 + if (pointer_set_contains(visited, def_stmt))
111182 + return expand_visited(def_stmt);
111183 +
111184 + switch (gimple_code(def_stmt)) {
111185 + case GIMPLE_PHI:
111186 + return handle_phi(visited, lhs);
111187 + case GIMPLE_CALL:
111188 + case GIMPLE_ASM:
111189 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111190 + case GIMPLE_ASSIGN:
111191 + switch (gimple_num_ops(def_stmt)) {
111192 + case 2:
111193 + return handle_unary_ops(visited, def_stmt);
111194 + case 3:
111195 + return handle_binary_ops(visited, lhs);
111196 +#if BUILDING_GCC_VERSION >= 4007
111197 + case 4:
111198 + return handle_ternary_ops(visited, lhs);
111199 +#endif
111200 + }
111201 + default:
111202 + debug_gimple_stmt(def_stmt);
111203 + error("%s: unknown gimple code", __func__);
111204 + gcc_unreachable();
111205 + }
111206 +}
111207 +
111208 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
111209 +{
111210 + const_gimple assign;
111211 + tree orig_type = TREE_TYPE(orig_node);
111212 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111213 +
111214 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111215 + return gimple_get_lhs(assign);
111216 +}
111217 +
111218 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
111219 +{
111220 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
111221 + update_stmt(stmt);
111222 +}
111223 +
111224 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
111225 +{
111226 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
111227 + update_stmt(stmt);
111228 +}
111229 +
111230 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
111231 +{
111232 + tree arg;
111233 + const_tree origarg;
111234 +
111235 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
111236 + return true;
111237 +
111238 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
111239 + while (origarg && *argnum) {
111240 + (*argnum)--;
111241 + origarg = TREE_CHAIN(origarg);
111242 + }
111243 +
111244 + gcc_assert(*argnum == 0);
111245 +
111246 + gcc_assert(origarg != NULL_TREE);
111247 + *argnum = 0;
111248 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
111249 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
111250 + return true;
111251 + return false;
111252 +}
111253 +
111254 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
111255 +{
111256 + gimple phi = get_def_stmt(result);
111257 + unsigned int i, n = gimple_phi_num_args(phi);
111258 +
111259 + if (!phi)
111260 + return MARK_NO;
111261 +
111262 + pointer_set_insert(visited, phi);
111263 + for (i = 0; i < n; i++) {
111264 + enum mark marked;
111265 + const_tree arg = gimple_phi_arg_def(phi, i);
111266 + marked = pre_expand(visited, search_err_code, arg);
111267 + if (marked != MARK_NO)
111268 + return marked;
111269 + }
111270 + return MARK_NO;
111271 +}
111272 +
111273 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
111274 +{
111275 + gimple def_stmt = get_def_stmt(lhs);
111276 + const_tree rhs;
111277 +
111278 + if (!def_stmt)
111279 + return MARK_NO;
111280 +
111281 + rhs = gimple_assign_rhs1(def_stmt);
111282 +
111283 + def_stmt = get_def_stmt(rhs);
111284 + if (is_gimple_constant(rhs))
111285 + search_err_code[FROM_CONST] = true;
111286 +
111287 + return pre_expand(visited, search_err_code, rhs);
111288 +}
111289 +
111290 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
111291 +{
111292 + gimple def_stmt = get_def_stmt(lhs);
111293 + const_tree rhs1, rhs2;
111294 + enum mark marked;
111295 +
111296 + if (!def_stmt)
111297 + return MARK_NO;
111298 +
111299 + search_err_code[CAST_ONLY] = false;
111300 +
111301 + rhs1 = gimple_assign_rhs1(def_stmt);
111302 + rhs2 = gimple_assign_rhs2(def_stmt);
111303 + marked = pre_expand(visited, search_err_code, rhs1);
111304 + if (marked != MARK_NO)
111305 + return marked;
111306 + return pre_expand(visited, search_err_code, rhs2);
111307 +}
111308 +
111309 +static const_tree search_field_decl(const_tree comp_ref)
111310 +{
111311 + const_tree field = NULL_TREE;
111312 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
111313 +
111314 + for (i = 0; i < len; i++) {
111315 + field = TREE_OPERAND(comp_ref, i);
111316 + if (TREE_CODE(field) == FIELD_DECL)
111317 + break;
111318 + }
111319 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
111320 + return field;
111321 +}
111322 +
111323 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
111324 +{
111325 + const_tree attr, p;
111326 +
111327 + // 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);
111328 + if (fndecl == NULL_TREE)
111329 + return MARK_NO;
111330 +
111331 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
111332 + if (!attr || !TREE_VALUE(attr))
111333 + return MARK_NO;
111334 +
111335 + p = TREE_VALUE(attr);
111336 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
111337 + return MARK_TURN_OFF;
111338 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
111339 + return MARK_NOT_INTENTIONAL;
111340 + if (argnum == 0) {
111341 + gcc_assert(current_function_decl == fndecl);
111342 + return MARK_NO;
111343 + }
111344 +
111345 + do {
111346 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
111347 + return MARK_YES;
111348 + p = TREE_CHAIN(p);
111349 + } while (p);
111350 +
111351 + return MARK_NO;
111352 +}
111353 +
111354 +static void print_missing_msg(tree func, unsigned int argnum)
111355 +{
111356 + unsigned int new_hash;
111357 + size_t len;
111358 + unsigned char tree_codes[CODES_LIMIT];
111359 + location_t loc;
111360 + const char *curfunc;
111361 +
111362 + func = get_original_function_decl(func);
111363 + loc = DECL_SOURCE_LOCATION(func);
111364 + curfunc = get_asm_name(func);
111365 +
111366 + len = get_function_decl(func, tree_codes);
111367 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
111368 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
111369 +}
111370 +
111371 +static unsigned int search_missing_attribute(const_tree arg)
111372 +{
111373 + unsigned int argnum;
111374 + const struct size_overflow_hash *hash;
111375 + const_tree type = TREE_TYPE(arg);
111376 + tree func = get_original_function_decl(current_function_decl);
111377 +
111378 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
111379 +
111380 + if (TREE_CODE(type) == POINTER_TYPE)
111381 + return 0;
111382 +
111383 + argnum = find_arg_number(arg, func);
111384 + if (argnum == 0)
111385 + return 0;
111386 +
111387 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
111388 + return argnum;
111389 +
111390 + hash = get_function_hash(func);
111391 + if (!hash || !(hash->param & (1U << argnum))) {
111392 + print_missing_msg(func, argnum);
111393 + return 0;
111394 + }
111395 + return argnum;
111396 +}
111397 +
111398 +static enum mark is_already_marked(const_tree lhs)
111399 +{
111400 + unsigned int argnum;
111401 + const_tree fndecl;
111402 +
111403 + argnum = search_missing_attribute(lhs);
111404 + fndecl = get_original_function_decl(current_function_decl);
111405 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
111406 + return MARK_YES;
111407 + return MARK_NO;
111408 +}
111409 +
111410 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
111411 +{
111412 + const_gimple def_stmt;
111413 +
111414 + if (skip_types(lhs))
111415 + return MARK_NO;
111416 +
111417 + if (TREE_CODE(lhs) == PARM_DECL)
111418 + return is_already_marked(lhs);
111419 +
111420 + if (TREE_CODE(lhs) == COMPONENT_REF) {
111421 + const_tree field, attr;
111422 +
111423 + field = search_field_decl(lhs);
111424 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
111425 + if (!attr || !TREE_VALUE(attr))
111426 + return MARK_NO;
111427 + return MARK_YES;
111428 + }
111429 +
111430 + def_stmt = get_def_stmt(lhs);
111431 +
111432 + if (!def_stmt)
111433 + return MARK_NO;
111434 +
111435 + if (pointer_set_contains(visited, def_stmt))
111436 + return MARK_NO;
111437 +
111438 + switch (gimple_code(def_stmt)) {
111439 + case GIMPLE_NOP:
111440 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
111441 + return is_already_marked(lhs);
111442 + return MARK_NO;
111443 + case GIMPLE_PHI:
111444 + return walk_phi(visited, search_err_code, lhs);
111445 + case GIMPLE_CALL:
111446 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
111447 + return MARK_TURN_OFF;
111448 + check_function_hash(def_stmt);
111449 + return MARK_NO;
111450 + case GIMPLE_ASM:
111451 + search_err_code[CAST_ONLY] = false;
111452 + return MARK_NO;
111453 + case GIMPLE_ASSIGN:
111454 + switch (gimple_num_ops(def_stmt)) {
111455 + case 2:
111456 + return walk_unary_ops(visited, search_err_code, lhs);
111457 + case 3:
111458 + return walk_binary_ops(visited, search_err_code, lhs);
111459 + }
111460 + default:
111461 + debug_gimple_stmt((gimple)def_stmt);
111462 + error("%s: unknown gimple code", __func__);
111463 + gcc_unreachable();
111464 + }
111465 +}
111466 +
111467 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
111468 +static bool skip_asm(const_tree arg)
111469 +{
111470 + gimple def_stmt = get_def_stmt(arg);
111471 +
111472 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111473 + return false;
111474 +
111475 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
111476 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
111477 +}
111478 +
111479 +/*
111480 +0</MARK_YES: no dup, search attributes (so, int)
111481 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
111482 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
111483 +*/
111484 +
111485 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
111486 +{
111487 + struct pointer_set_t *visited;
111488 + enum mark is_marked, is_found;
111489 + location_t loc;
111490 + bool search_err_code[2] = {true, false};
111491 +
111492 + is_marked = mark_status(current_function_decl, 0);
111493 + if (is_marked == MARK_TURN_OFF)
111494 + return true;
111495 +
111496 + is_marked = mark_status(fndecl, argnum + 1);
111497 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
111498 + return true;
111499 +
111500 + visited = pointer_set_create();
111501 + is_found = pre_expand(visited, search_err_code, arg);
111502 + pointer_set_destroy(visited);
111503 +
111504 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
111505 + return true;
111506 +
111507 + if (where == FROM_ARG && skip_asm(arg))
111508 + return true;
111509 +
111510 + if (is_found == MARK_TURN_OFF)
111511 + return true;
111512 +
111513 + if ((is_found == MARK_YES && is_marked == MARK_YES))
111514 + return true;
111515 +
111516 + if (is_found == MARK_YES) {
111517 + loc = DECL_SOURCE_LOCATION(fndecl);
111518 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
111519 + return true;
111520 + }
111521 + return false;
111522 +}
111523 +
111524 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
111525 +{
111526 + struct pointer_set_t *visited;
111527 + tree arg, new_arg;
111528 + bool match;
111529 +
111530 + if (argnum == 0)
111531 + return;
111532 +
111533 + argnum--;
111534 +
111535 + match = get_function_arg(&argnum, fndecl);
111536 + if (!match)
111537 + return;
111538 + gcc_assert(gimple_call_num_args(stmt) > argnum);
111539 + arg = gimple_call_arg(stmt, argnum);
111540 + if (arg == NULL_TREE)
111541 + return;
111542 +
111543 + if (skip_types(arg))
111544 + return;
111545 +
111546 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
111547 + return;
111548 +
111549 + visited = pointer_set_create();
111550 + new_arg = expand(visited, arg);
111551 + pointer_set_destroy(visited);
111552 +
111553 + if (new_arg == NULL_TREE)
111554 + return;
111555 +
111556 + change_function_arg(stmt, arg, argnum, new_arg);
111557 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
111558 +}
111559 +
111560 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
111561 +{
111562 + tree p = TREE_VALUE(attr);
111563 + do {
111564 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
111565 + p = TREE_CHAIN(p);
111566 + } while (p);
111567 +}
111568 +
111569 +static void handle_function_by_hash(gimple stmt, tree fndecl)
111570 +{
111571 + unsigned int num;
111572 + const struct size_overflow_hash *hash;
111573 +
111574 + hash = get_function_hash(fndecl);
111575 + if (!hash)
111576 + return;
111577 +
111578 + for (num = 0; num <= MAX_PARAM; num++)
111579 + if (hash->param & (1U << num))
111580 + handle_function_arg(stmt, fndecl, num);
111581 +}
111582 +
111583 +static bool check_return_value(void)
111584 +{
111585 + const struct size_overflow_hash *hash;
111586 +
111587 + hash = get_function_hash(current_function_decl);
111588 + if (!hash || !(hash->param & 1U << 0))
111589 + return false;
111590 +
111591 + return true;
111592 +}
111593 +
111594 +static void handle_return_value(gimple ret_stmt)
111595 +{
111596 + struct pointer_set_t *visited;
111597 + tree ret, new_ret;
111598 +
111599 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
111600 + return;
111601 +
111602 + ret = gimple_return_retval(ret_stmt);
111603 +
111604 + if (skip_types(ret))
111605 + return;
111606 +
111607 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
111608 + return;
111609 +
111610 + visited = pointer_set_create();
111611 + new_ret = expand(visited, ret);
111612 + pointer_set_destroy(visited);
111613 +
111614 + change_function_return(ret_stmt, ret, new_ret);
111615 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
111616 +}
111617 +
111618 +static void set_plf_false(void)
111619 +{
111620 + basic_block bb;
111621 +
111622 + FOR_ALL_BB(bb) {
111623 + gimple_stmt_iterator si;
111624 +
111625 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
111626 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
111627 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
111628 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
111629 + }
111630 +}
111631 +
111632 +static unsigned int handle_function(void)
111633 +{
111634 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
111635 + bool check_ret;
111636 +
111637 + set_plf_false();
111638 +
111639 + check_ret = check_return_value();
111640 +
111641 + do {
111642 + gimple_stmt_iterator gsi;
111643 + next = bb->next_bb;
111644 +
111645 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
111646 + tree fndecl, attr;
111647 + gimple stmt = gsi_stmt(gsi);
111648 +
111649 + if (check_ret)
111650 + handle_return_value(stmt);
111651 +
111652 + if (!(is_gimple_call(stmt)))
111653 + continue;
111654 + fndecl = gimple_call_fndecl(stmt);
111655 + if (fndecl == NULL_TREE)
111656 + continue;
111657 + if (gimple_call_num_args(stmt) == 0)
111658 + continue;
111659 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
111660 + if (!attr || !TREE_VALUE(attr))
111661 + handle_function_by_hash(stmt, fndecl);
111662 + else
111663 + handle_function_by_attribute(stmt, attr, fndecl);
111664 + gsi = gsi_for_stmt(stmt);
111665 + next = gimple_bb(stmt)->next_bb;
111666 + }
111667 + bb = next;
111668 + } while (bb);
111669 + return 0;
111670 +}
111671 +
111672 +static struct gimple_opt_pass size_overflow_pass = {
111673 + .pass = {
111674 + .type = GIMPLE_PASS,
111675 + .name = "size_overflow",
111676 +#if BUILDING_GCC_VERSION >= 4008
111677 + .optinfo_flags = OPTGROUP_NONE,
111678 +#endif
111679 + .gate = NULL,
111680 + .execute = handle_function,
111681 + .sub = NULL,
111682 + .next = NULL,
111683 + .static_pass_number = 0,
111684 + .tv_id = TV_NONE,
111685 + .properties_required = PROP_cfg,
111686 + .properties_provided = 0,
111687 + .properties_destroyed = 0,
111688 + .todo_flags_start = 0,
111689 + .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
111690 + }
111691 +};
111692 +
111693 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
111694 +{
111695 + tree fntype;
111696 +
111697 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
111698 +
111699 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
111700 + fntype = build_function_type_list(void_type_node,
111701 + const_char_ptr_type_node,
111702 + unsigned_type_node,
111703 + const_char_ptr_type_node,
111704 + const_char_ptr_type_node,
111705 + NULL_TREE);
111706 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
111707 +
111708 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
111709 + TREE_PUBLIC(report_size_overflow_decl) = 1;
111710 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
111711 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
111712 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
111713 +}
111714 +
111715 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111716 +{
111717 + int i;
111718 + const char * const plugin_name = plugin_info->base_name;
111719 + const int argc = plugin_info->argc;
111720 + const struct plugin_argument * const argv = plugin_info->argv;
111721 + bool enable = true;
111722 +
111723 + struct register_pass_info size_overflow_pass_info = {
111724 + .pass = &size_overflow_pass.pass,
111725 + .reference_pass_name = "ssa",
111726 + .ref_pass_instance_number = 1,
111727 + .pos_op = PASS_POS_INSERT_AFTER
111728 + };
111729 +
111730 + if (!plugin_default_version_check(version, &gcc_version)) {
111731 + error(G_("incompatible gcc/plugin versions"));
111732 + return 1;
111733 + }
111734 +
111735 + for (i = 0; i < argc; ++i) {
111736 + if (!strcmp(argv[i].key, "no-size-overflow")) {
111737 + enable = false;
111738 + continue;
111739 + }
111740 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111741 + }
111742 +
111743 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
111744 + if (enable) {
111745 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
111746 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
111747 + }
111748 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
111749 +
111750 + return 0;
111751 +}
111752 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
111753 new file mode 100644
111754 index 0000000..ac2901e
111755 --- /dev/null
111756 +++ b/tools/gcc/stackleak_plugin.c
111757 @@ -0,0 +1,327 @@
111758 +/*
111759 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
111760 + * Licensed under the GPL v2
111761 + *
111762 + * Note: the choice of the license means that the compilation process is
111763 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
111764 + * but for the kernel it doesn't matter since it doesn't link against
111765 + * any of the gcc libraries
111766 + *
111767 + * gcc plugin to help implement various PaX features
111768 + *
111769 + * - track lowest stack pointer
111770 + *
111771 + * TODO:
111772 + * - initialize all local variables
111773 + *
111774 + * BUGS:
111775 + * - none known
111776 + */
111777 +#include "gcc-plugin.h"
111778 +#include "config.h"
111779 +#include "system.h"
111780 +#include "coretypes.h"
111781 +#include "tree.h"
111782 +#include "tree-pass.h"
111783 +#include "flags.h"
111784 +#include "intl.h"
111785 +#include "toplev.h"
111786 +#include "plugin.h"
111787 +//#include "expr.h" where are you...
111788 +#include "diagnostic.h"
111789 +#include "plugin-version.h"
111790 +#include "tm.h"
111791 +#include "function.h"
111792 +#include "basic-block.h"
111793 +#include "gimple.h"
111794 +#include "rtl.h"
111795 +#include "emit-rtl.h"
111796 +
111797 +#if BUILDING_GCC_VERSION >= 4008
111798 +#define TODO_dump_func 0
111799 +#endif
111800 +
111801 +extern void print_gimple_stmt(FILE *, gimple, int, int);
111802 +
111803 +int plugin_is_GPL_compatible;
111804 +
111805 +static int track_frame_size = -1;
111806 +static const char track_function[] = "pax_track_stack";
111807 +static const char check_function[] = "pax_check_alloca";
111808 +static bool init_locals;
111809 +
111810 +static struct plugin_info stackleak_plugin_info = {
111811 + .version = "201302112000",
111812 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
111813 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
111814 +};
111815 +
111816 +static bool gate_stackleak_track_stack(void);
111817 +static unsigned int execute_stackleak_tree_instrument(void);
111818 +static unsigned int execute_stackleak_final(void);
111819 +
111820 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
111821 + .pass = {
111822 + .type = GIMPLE_PASS,
111823 + .name = "stackleak_tree_instrument",
111824 +#if BUILDING_GCC_VERSION >= 4008
111825 + .optinfo_flags = OPTGROUP_NONE,
111826 +#endif
111827 + .gate = gate_stackleak_track_stack,
111828 + .execute = execute_stackleak_tree_instrument,
111829 + .sub = NULL,
111830 + .next = NULL,
111831 + .static_pass_number = 0,
111832 + .tv_id = TV_NONE,
111833 + .properties_required = PROP_gimple_leh | PROP_cfg,
111834 + .properties_provided = 0,
111835 + .properties_destroyed = 0,
111836 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
111837 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
111838 + }
111839 +};
111840 +
111841 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
111842 + .pass = {
111843 + .type = RTL_PASS,
111844 + .name = "stackleak_final",
111845 +#if BUILDING_GCC_VERSION >= 4008
111846 + .optinfo_flags = OPTGROUP_NONE,
111847 +#endif
111848 + .gate = gate_stackleak_track_stack,
111849 + .execute = execute_stackleak_final,
111850 + .sub = NULL,
111851 + .next = NULL,
111852 + .static_pass_number = 0,
111853 + .tv_id = TV_NONE,
111854 + .properties_required = 0,
111855 + .properties_provided = 0,
111856 + .properties_destroyed = 0,
111857 + .todo_flags_start = 0,
111858 + .todo_flags_finish = TODO_dump_func
111859 + }
111860 +};
111861 +
111862 +static bool gate_stackleak_track_stack(void)
111863 +{
111864 + return track_frame_size >= 0;
111865 +}
111866 +
111867 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
111868 +{
111869 + gimple check_alloca;
111870 + tree fntype, fndecl, alloca_size;
111871 +
111872 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
111873 + fndecl = build_fn_decl(check_function, fntype);
111874 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
111875 +
111876 + // insert call to void pax_check_alloca(unsigned long size)
111877 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
111878 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
111879 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
111880 +}
111881 +
111882 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
111883 +{
111884 + gimple track_stack;
111885 + tree fntype, fndecl;
111886 +
111887 + fntype = build_function_type_list(void_type_node, NULL_TREE);
111888 + fndecl = build_fn_decl(track_function, fntype);
111889 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
111890 +
111891 + // insert call to void pax_track_stack(void)
111892 + track_stack = gimple_build_call(fndecl, 0);
111893 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
111894 +}
111895 +
111896 +#if BUILDING_GCC_VERSION == 4005
111897 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
111898 +{
111899 + tree fndecl;
111900 +
111901 + if (!is_gimple_call(stmt))
111902 + return false;
111903 + fndecl = gimple_call_fndecl(stmt);
111904 + if (!fndecl)
111905 + return false;
111906 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
111907 + return false;
111908 +// print_node(stderr, "pax", fndecl, 4);
111909 + return DECL_FUNCTION_CODE(fndecl) == code;
111910 +}
111911 +#endif
111912 +
111913 +static bool is_alloca(gimple stmt)
111914 +{
111915 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
111916 + return true;
111917 +
111918 +#if BUILDING_GCC_VERSION >= 4007
111919 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
111920 + return true;
111921 +#endif
111922 +
111923 + return false;
111924 +}
111925 +
111926 +static unsigned int execute_stackleak_tree_instrument(void)
111927 +{
111928 + basic_block bb, entry_bb;
111929 + bool prologue_instrumented = false, is_leaf = true;
111930 +
111931 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
111932 +
111933 + // 1. loop through BBs and GIMPLE statements
111934 + FOR_EACH_BB(bb) {
111935 + gimple_stmt_iterator gsi;
111936 +
111937 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
111938 + gimple stmt;
111939 +
111940 + stmt = gsi_stmt(gsi);
111941 +
111942 + if (is_gimple_call(stmt))
111943 + is_leaf = false;
111944 +
111945 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
111946 + if (!is_alloca(stmt))
111947 + continue;
111948 +
111949 + // 2. insert stack overflow check before each __builtin_alloca call
111950 + stackleak_check_alloca(&gsi);
111951 +
111952 + // 3. insert track call after each __builtin_alloca call
111953 + stackleak_add_instrumentation(&gsi);
111954 + if (bb == entry_bb)
111955 + prologue_instrumented = true;
111956 + }
111957 + }
111958 +
111959 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
111960 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
111961 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
111962 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
111963 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
111964 + return 0;
111965 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
111966 + return 0;
111967 +
111968 + // 4. insert track call at the beginning
111969 + if (!prologue_instrumented) {
111970 + gimple_stmt_iterator gsi;
111971 +
111972 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111973 + if (dom_info_available_p(CDI_DOMINATORS))
111974 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
111975 + gsi = gsi_start_bb(bb);
111976 + stackleak_add_instrumentation(&gsi);
111977 + }
111978 +
111979 + return 0;
111980 +}
111981 +
111982 +static unsigned int execute_stackleak_final(void)
111983 +{
111984 + rtx insn, next;
111985 +
111986 + if (cfun->calls_alloca)
111987 + return 0;
111988 +
111989 + // keep calls only if function frame is big enough
111990 + if (get_frame_size() >= track_frame_size)
111991 + return 0;
111992 +
111993 + // 1. find pax_track_stack calls
111994 + for (insn = get_insns(); insn; insn = next) {
111995 + // 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))
111996 + rtx body;
111997 +
111998 + next = NEXT_INSN(insn);
111999 + if (!CALL_P(insn))
112000 + continue;
112001 + body = PATTERN(insn);
112002 + if (GET_CODE(body) != CALL)
112003 + continue;
112004 + body = XEXP(body, 0);
112005 + if (GET_CODE(body) != MEM)
112006 + continue;
112007 + body = XEXP(body, 0);
112008 + if (GET_CODE(body) != SYMBOL_REF)
112009 + continue;
112010 + if (strcmp(XSTR(body, 0), track_function))
112011 + continue;
112012 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
112013 + // 2. delete call
112014 + delete_insn_and_edges(insn);
112015 +#if BUILDING_GCC_VERSION >= 4007
112016 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
112017 + insn = next;
112018 + next = NEXT_INSN(insn);
112019 + delete_insn_and_edges(insn);
112020 + }
112021 +#endif
112022 + }
112023 +
112024 +// print_simple_rtl(stderr, get_insns());
112025 +// print_rtl(stderr, get_insns());
112026 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
112027 +
112028 + return 0;
112029 +}
112030 +
112031 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
112032 +{
112033 + const char * const plugin_name = plugin_info->base_name;
112034 + const int argc = plugin_info->argc;
112035 + const struct plugin_argument * const argv = plugin_info->argv;
112036 + int i;
112037 + struct register_pass_info stackleak_tree_instrument_pass_info = {
112038 + .pass = &stackleak_tree_instrument_pass.pass,
112039 +// .reference_pass_name = "tree_profile",
112040 + .reference_pass_name = "optimized",
112041 + .ref_pass_instance_number = 1,
112042 + .pos_op = PASS_POS_INSERT_BEFORE
112043 + };
112044 + struct register_pass_info stackleak_final_pass_info = {
112045 + .pass = &stackleak_final_rtl_opt_pass.pass,
112046 + .reference_pass_name = "final",
112047 + .ref_pass_instance_number = 1,
112048 + .pos_op = PASS_POS_INSERT_BEFORE
112049 + };
112050 +
112051 + if (!plugin_default_version_check(version, &gcc_version)) {
112052 + error(G_("incompatible gcc/plugin versions"));
112053 + return 1;
112054 + }
112055 +
112056 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
112057 +
112058 + for (i = 0; i < argc; ++i) {
112059 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
112060 + if (!argv[i].value) {
112061 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
112062 + continue;
112063 + }
112064 + track_frame_size = atoi(argv[i].value);
112065 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
112066 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
112067 + continue;
112068 + }
112069 + if (!strcmp(argv[i].key, "initialize-locals")) {
112070 + if (argv[i].value) {
112071 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
112072 + continue;
112073 + }
112074 + init_locals = true;
112075 + continue;
112076 + }
112077 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
112078 + }
112079 +
112080 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
112081 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
112082 +
112083 + return 0;
112084 +}
112085 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
112086 new file mode 100644
112087 index 0000000..4fae911
112088 --- /dev/null
112089 +++ b/tools/gcc/structleak_plugin.c
112090 @@ -0,0 +1,277 @@
112091 +/*
112092 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
112093 + * Licensed under the GPL v2
112094 + *
112095 + * Note: the choice of the license means that the compilation process is
112096 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
112097 + * but for the kernel it doesn't matter since it doesn't link against
112098 + * any of the gcc libraries
112099 + *
112100 + * gcc plugin to forcibly initialize certain local variables that could
112101 + * otherwise leak kernel stack to userland if they aren't properly initialized
112102 + * by later code
112103 + *
112104 + * Homepage: http://pax.grsecurity.net/
112105 + *
112106 + * Usage:
112107 + * $ # for 4.5/4.6/C based 4.7
112108 + * $ 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
112109 + * $ # for C++ based 4.7/4.8+
112110 + * $ 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
112111 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
112112 + *
112113 + * TODO: eliminate redundant initializers
112114 + * increase type coverage
112115 + */
112116 +
112117 +#include "gcc-plugin.h"
112118 +#include "config.h"
112119 +#include "system.h"
112120 +#include "coretypes.h"
112121 +#include "tree.h"
112122 +#include "tree-pass.h"
112123 +#include "intl.h"
112124 +#include "plugin-version.h"
112125 +#include "tm.h"
112126 +#include "toplev.h"
112127 +#include "function.h"
112128 +#include "tree-flow.h"
112129 +#include "plugin.h"
112130 +#include "gimple.h"
112131 +#include "diagnostic.h"
112132 +#include "cfgloop.h"
112133 +#include "langhooks.h"
112134 +
112135 +#if BUILDING_GCC_VERSION >= 4008
112136 +#define TODO_dump_func 0
112137 +#endif
112138 +
112139 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
112140 +
112141 +// unused type flag in all versions 4.5-4.8
112142 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
112143 +
112144 +int plugin_is_GPL_compatible;
112145 +void debug_gimple_stmt(gimple gs);
112146 +
112147 +static struct plugin_info structleak_plugin_info = {
112148 + .version = "201304082245",
112149 + .help = "disable\tdo not activate plugin\n",
112150 +};
112151 +
112152 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
112153 +{
112154 + *no_add_attrs = true;
112155 +
112156 + // check for types? for now accept everything linux has to offer
112157 + if (TREE_CODE(*node) != FIELD_DECL)
112158 + return NULL_TREE;
112159 +
112160 + *no_add_attrs = false;
112161 + return NULL_TREE;
112162 +}
112163 +
112164 +static struct attribute_spec user_attr = {
112165 + .name = "user",
112166 + .min_length = 0,
112167 + .max_length = 0,
112168 + .decl_required = false,
112169 + .type_required = false,
112170 + .function_type_required = false,
112171 + .handler = handle_user_attribute,
112172 +#if BUILDING_GCC_VERSION >= 4007
112173 + .affects_type_identity = true
112174 +#endif
112175 +};
112176 +
112177 +static void register_attributes(void *event_data, void *data)
112178 +{
112179 + register_attribute(&user_attr);
112180 +// register_attribute(&force_attr);
112181 +}
112182 +
112183 +static tree get_field_type(tree field)
112184 +{
112185 + return strip_array_types(TREE_TYPE(field));
112186 +}
112187 +
112188 +static bool is_userspace_type(tree type)
112189 +{
112190 + tree field;
112191 +
112192 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
112193 + tree fieldtype = get_field_type(field);
112194 + enum tree_code code = TREE_CODE(fieldtype);
112195 +
112196 + if (code == RECORD_TYPE || code == UNION_TYPE)
112197 + if (is_userspace_type(fieldtype))
112198 + return true;
112199 +
112200 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
112201 + return true;
112202 + }
112203 + return false;
112204 +}
112205 +
112206 +static void finish_type(void *event_data, void *data)
112207 +{
112208 + tree type = (tree)event_data;
112209 +
112210 + if (TYPE_USERSPACE(type))
112211 + return;
112212 +
112213 + if (is_userspace_type(type))
112214 + TYPE_USERSPACE(type) = 1;
112215 +}
112216 +
112217 +static void initialize(tree var)
112218 +{
112219 + basic_block bb;
112220 + gimple_stmt_iterator gsi;
112221 + tree initializer;
112222 + gimple init_stmt;
112223 +
112224 + // this is the original entry bb before the forced split
112225 + // TODO: check further BBs in case more splits occured before us
112226 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
112227 +
112228 + // first check if the variable is already initialized, warn otherwise
112229 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112230 + gimple stmt = gsi_stmt(gsi);
112231 + tree rhs1;
112232 +
112233 + // we're looking for an assignment of a single rhs...
112234 + if (!gimple_assign_single_p(stmt))
112235 + continue;
112236 + rhs1 = gimple_assign_rhs1(stmt);
112237 +#if BUILDING_GCC_VERSION >= 4007
112238 + // ... of a non-clobbering expression...
112239 + if (TREE_CLOBBER_P(rhs1))
112240 + continue;
112241 +#endif
112242 + // ... to our variable...
112243 + if (gimple_get_lhs(stmt) != var)
112244 + continue;
112245 + // if it's an initializer then we're good
112246 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
112247 + return;
112248 + }
112249 +
112250 + // these aren't the 0days you're looking for
112251 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
112252 +
112253 + // build the initializer expression
112254 + initializer = build_constructor(TREE_TYPE(var), NULL);
112255 +
112256 + // build the initializer stmt
112257 + init_stmt = gimple_build_assign(var, initializer);
112258 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
112259 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
112260 + update_stmt(init_stmt);
112261 +}
112262 +
112263 +static unsigned int handle_function(void)
112264 +{
112265 + basic_block bb;
112266 + unsigned int ret = 0;
112267 + tree var;
112268 +
112269 +#if BUILDING_GCC_VERSION == 4005
112270 + tree vars;
112271 +#else
112272 + unsigned int i;
112273 +#endif
112274 +
112275 + // split the first bb where we can put the forced initializers
112276 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
112277 + if (dom_info_available_p(CDI_DOMINATORS))
112278 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
112279 +
112280 + // enumarate all local variables and forcibly initialize our targets
112281 +#if BUILDING_GCC_VERSION == 4005
112282 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
112283 + var = TREE_VALUE(vars);
112284 +#else
112285 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
112286 +#endif
112287 + tree type = TREE_TYPE(var);
112288 +
112289 + gcc_assert(DECL_P(var));
112290 + if (!auto_var_in_fn_p(var, current_function_decl))
112291 + continue;
112292 +
112293 + // only care about structure types
112294 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
112295 + continue;
112296 +
112297 + // if the type is of interest, examine the variable
112298 + if (TYPE_USERSPACE(type))
112299 + initialize(var);
112300 + }
112301 +
112302 + return ret;
112303 +}
112304 +
112305 +static struct gimple_opt_pass structleak_pass = {
112306 + .pass = {
112307 + .type = GIMPLE_PASS,
112308 + .name = "structleak",
112309 +#if BUILDING_GCC_VERSION >= 4008
112310 + .optinfo_flags = OPTGROUP_NONE,
112311 +#endif
112312 + .gate = NULL,
112313 + .execute = handle_function,
112314 + .sub = NULL,
112315 + .next = NULL,
112316 + .static_pass_number = 0,
112317 + .tv_id = TV_NONE,
112318 + .properties_required = PROP_cfg,
112319 + .properties_provided = 0,
112320 + .properties_destroyed = 0,
112321 + .todo_flags_start = 0,
112322 + .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
112323 + }
112324 +};
112325 +
112326 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
112327 +{
112328 + int i;
112329 + const char * const plugin_name = plugin_info->base_name;
112330 + const int argc = plugin_info->argc;
112331 + const struct plugin_argument * const argv = plugin_info->argv;
112332 + bool enable = true;
112333 +
112334 + struct register_pass_info structleak_pass_info = {
112335 + .pass = &structleak_pass.pass,
112336 + .reference_pass_name = "ssa",
112337 + .ref_pass_instance_number = 1,
112338 + .pos_op = PASS_POS_INSERT_AFTER
112339 + };
112340 +
112341 + if (!plugin_default_version_check(version, &gcc_version)) {
112342 + error(G_("incompatible gcc/plugin versions"));
112343 + return 1;
112344 + }
112345 +
112346 + if (strcmp(lang_hooks.name, "GNU C")) {
112347 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
112348 + enable = false;
112349 + }
112350 +
112351 + for (i = 0; i < argc; ++i) {
112352 + if (!strcmp(argv[i].key, "disable")) {
112353 + enable = false;
112354 + continue;
112355 + }
112356 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
112357 + }
112358 +
112359 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
112360 + if (enable) {
112361 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
112362 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
112363 + }
112364 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
112365 +
112366 + return 0;
112367 +}
112368 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
112369 index 926cbf3..b8403e0 100644
112370 --- a/tools/lib/lk/Makefile
112371 +++ b/tools/lib/lk/Makefile
112372 @@ -10,7 +10,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
112373
112374 LIBFILE = liblk.a
112375
112376 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
112377 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
112378 EXTLIBS = -lpthread -lrt -lelf -lm
112379 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
112380 ALL_LDFLAGS = $(LDFLAGS)
112381 diff --git a/tools/perf/Makefile b/tools/perf/Makefile
112382 index b0f164b..63c9f7d 100644
112383 --- a/tools/perf/Makefile
112384 +++ b/tools/perf/Makefile
112385 @@ -188,7 +188,7 @@ endif
112386
112387 ifndef PERF_DEBUG
112388 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
112389 - CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2
112390 + CFLAGS := $(CFLAGS) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
112391 endif
112392 endif
112393
112394 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
112395 index 6789d78..4afd019e 100644
112396 --- a/tools/perf/util/include/asm/alternative-asm.h
112397 +++ b/tools/perf/util/include/asm/alternative-asm.h
112398 @@ -5,4 +5,7 @@
112399
112400 #define altinstruction_entry #
112401
112402 + .macro pax_force_retaddr rip=0, reload=0
112403 + .endm
112404 +
112405 #endif
112406 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
112407 index 96b919d..c49bb74 100644
112408 --- a/tools/perf/util/include/linux/compiler.h
112409 +++ b/tools/perf/util/include/linux/compiler.h
112410 @@ -18,4 +18,12 @@
112411 #define __force
112412 #endif
112413
112414 +#ifndef __size_overflow
112415 +# define __size_overflow(...)
112416 +#endif
112417 +
112418 +#ifndef __intentional_overflow
112419 +# define __intentional_overflow(...)
112420 +#endif
112421 +
112422 #endif
112423 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
112424 index 302681c..3bde377 100644
112425 --- a/virt/kvm/kvm_main.c
112426 +++ b/virt/kvm/kvm_main.c
112427 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
112428
112429 static cpumask_var_t cpus_hardware_enabled;
112430 static int kvm_usage_count = 0;
112431 -static atomic_t hardware_enable_failed;
112432 +static atomic_unchecked_t hardware_enable_failed;
112433
112434 struct kmem_cache *kvm_vcpu_cache;
112435 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
112436
112437 -static __read_mostly struct preempt_ops kvm_preempt_ops;
112438 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
112439 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
112440 +static struct preempt_ops kvm_preempt_ops = {
112441 + .sched_in = kvm_sched_in,
112442 + .sched_out = kvm_sched_out,
112443 +};
112444
112445 struct dentry *kvm_debugfs_dir;
112446
112447 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
112448 /* We can read the guest memory with __xxx_user() later on. */
112449 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
112450 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
112451 - !access_ok(VERIFY_WRITE,
112452 + !__access_ok(VERIFY_WRITE,
112453 (void __user *)(unsigned long)mem->userspace_addr,
112454 mem->memory_size)))
112455 goto out;
112456 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
112457 return 0;
112458 }
112459
112460 -static struct file_operations kvm_vcpu_fops = {
112461 +static file_operations_no_const kvm_vcpu_fops __read_only = {
112462 .release = kvm_vcpu_release,
112463 .unlocked_ioctl = kvm_vcpu_ioctl,
112464 #ifdef CONFIG_COMPAT
112465 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
112466 return 0;
112467 }
112468
112469 -static struct file_operations kvm_vm_fops = {
112470 +static file_operations_no_const kvm_vm_fops __read_only = {
112471 .release = kvm_vm_release,
112472 .unlocked_ioctl = kvm_vm_ioctl,
112473 #ifdef CONFIG_COMPAT
112474 @@ -2662,7 +2667,7 @@ out:
112475 return r;
112476 }
112477
112478 -static struct file_operations kvm_chardev_ops = {
112479 +static file_operations_no_const kvm_chardev_ops __read_only = {
112480 .unlocked_ioctl = kvm_dev_ioctl,
112481 .compat_ioctl = kvm_dev_ioctl,
112482 .llseek = noop_llseek,
112483 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
112484
112485 if (r) {
112486 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
112487 - atomic_inc(&hardware_enable_failed);
112488 + atomic_inc_unchecked(&hardware_enable_failed);
112489 printk(KERN_INFO "kvm: enabling virtualization on "
112490 "CPU%d failed\n", cpu);
112491 }
112492 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
112493
112494 kvm_usage_count++;
112495 if (kvm_usage_count == 1) {
112496 - atomic_set(&hardware_enable_failed, 0);
112497 + atomic_set_unchecked(&hardware_enable_failed, 0);
112498 on_each_cpu(hardware_enable_nolock, NULL, 1);
112499
112500 - if (atomic_read(&hardware_enable_failed)) {
112501 + if (atomic_read_unchecked(&hardware_enable_failed)) {
112502 hardware_disable_all_nolock();
112503 r = -EBUSY;
112504 }
112505 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
112506 kvm_arch_vcpu_put(vcpu);
112507 }
112508
112509 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112510 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112511 struct module *module)
112512 {
112513 int r;
112514 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112515 if (!vcpu_align)
112516 vcpu_align = __alignof__(struct kvm_vcpu);
112517 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
112518 - 0, NULL);
112519 + SLAB_USERCOPY, NULL);
112520 if (!kvm_vcpu_cache) {
112521 r = -ENOMEM;
112522 goto out_free_3;
112523 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112524 if (r)
112525 goto out_free;
112526
112527 + pax_open_kernel();
112528 kvm_chardev_ops.owner = module;
112529 kvm_vm_fops.owner = module;
112530 kvm_vcpu_fops.owner = module;
112531 + pax_close_kernel();
112532
112533 r = misc_register(&kvm_dev);
112534 if (r) {
112535 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112536
112537 register_syscore_ops(&kvm_syscore_ops);
112538
112539 - kvm_preempt_ops.sched_in = kvm_sched_in;
112540 - kvm_preempt_ops.sched_out = kvm_sched_out;
112541 -
112542 r = kvm_init_debug();
112543 if (r) {
112544 printk(KERN_ERR "kvm: create debugfs files failed\n");